Documente Academic
Documente Profesional
Documente Cultură
Modified by on 11-Jul-2014
Model can be used in VBScripts to deal with PCB objects on a PCB document, or the Workspace
Manager Object Model to work with Projects and their documents to extract netlist data.
Refer to the general Scripting resources for information on using Altium Designer Object Models.
The Scripting Reference contains information on interfaces with respect to Altium Designer Object
Models, components, global routines, types, and variables that make up this scripting language.
Consult the Microsoft Visual Basic documentation for more information on VBScript functions.
Server Processes
A script can can be used to execute server processes, which represent commands in Altium Designer.
Refer to the Server Process Reference for more information on server processes and parameters.
VBScript examples
The simple examples included in this reference illustrate the basic features of VBScript programming
in Altium Designer.
For more VBScript examples see the ..\VBScripts folder in the downloadable example scripts
collection for Altium Designer.
The VBScripts can use script forms, script units, functions and objects from the Altium Designer
scripting API, and a subset of functions and objects from the Embarcadero Delphi RTL that are
exposed in the scripting system.
Sub Example
Dim X
Dim s
' x set to 0
x = 0
' s set to empty
s = ""
End Sub
Function Addone(value)
AddOne = Value + 1
End Function
Another Function example
Function Test(s)
Test = S + " rules.."
End Function
Sub DisplayName (sName)
MsgBox sName
End Sub
Sub Main
Dim S
S = "Altium Designer"
DisplayName Test(s)
End Sub
Parameters and Arguments
In VBScript a procedure declaration normally has a list of parameters note that variables are
considered typeless and the scripting system works out automatically what the variable types are.
The value used in place of the parameter when you make a procedure call is called an argument.
Example of a subroutine with a parameter
Sub Main
DisplayName "Altium Designer
End Sub
Rules"
Note that the use of the Call keyword to invoke a subroutine or a function is optional (maintained for
backward compatibility).
Comments in scripts
In a script, comments are non-executed lines of code that are included for the benefit of the
programmer. Comments can be included virtually anywhere in a script.
With VBScript comments:
Example
If Not (PcbApi_ChooseRectangleByCorners(BoardHandle,_
Choose first corner,_
Choose final corner,_
x1,y1,x2,y2)) Then EndIf
no need to instantiate an interface. The interface representing an existing Altium Designer object is
extracted, and from this interface the embedded or aggregate interface objects can be extracted to
get or set their property values.
To access a PCB document and its data objects, you first invoke the PCBServer function. By
convention, interface names are prefixed by an I character for example IPCB_Board represents
an interface for an existing PCB document in Altium Designer.
Example
Sub ViaCreation
Dim Board
Dim Via
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub
' Create a Via object
Via = PCBServer.PCBObjectFactory(eViaObject, eNoDimension, eCreate_Default)
Via.X = MilsToCoord(7500)
Via.Y = MilsToCoord(7500)
Via.Size
= MilsToCoord(50)
Via.HoleSize
= MilsToCoord(20)
Via.LowLayer
= eTopLayer
Via.HighLayer = eBottomLayer
' Put this via in the Board object
Board.AddPCBObject(Via)
End Sub
Client API
PCB Server API
Schematic Server API
Work Space Manager Server API
Nexus API
Altium Designer API functions
Parametric processes.
Refer to the main Scripting documentation for information on getting started with and building script
projects.
Refer to the Using the Altium Designer API guide for details on how to use design objects and their
interfaces in scripts.