Contact our corporate or local offices directly.
Scripting provides a powerful method of increasing your capabilities and productivity with Altium Designer. Scripts can be written in a number of languages, complete with sophisticated dialogs, and debugged within Altium Designer. You can use scripts to achieve your design objectives with minimal user input – fewer keyboard presses and mouse clicks!
With scripts, you can automate repetitive tasks and perform edits that are not available with the existing commands in Altium Designer. For example, you could use a script to search and update fiducial marks on a PCB document, or to export a customized netlist.
Scripts can be saved in a script project or in a design project. There are several script languages available to write scripts in Altium Designer.
The Altium Designer scripting system provides all the tools and features needed to create scripts that automate tasks in the software.
Scripts can be written to automate repetitive tasks or enhance a feature in Altium Designer. The scripting system is composed of two main parts: the Editor and the Debugger. The script editor, debugger, and scripting panels work together to help you write and debug your scripts easily. A script can be run directly from the script editor or assigned to a menu, toolbar, or hotkey so that it can be applied to the current document – such as a PCB Layout – at any time.
► Read about Scripting System in Altium Designer
Altium Designer scripts are usually created and stored in a Script Project (
*.PrjScr), but can be added to or stored in any type of project.
To begin writing scripts, start by creating a new script project and adding script files to that project.
A Script Project helps you manage your scripts, and can be created by selecting File » New » Project » Script Project from the main menu. A new project to store scripts will be listed in the Projects panel. To add a new script to the project, right-click on the project name and select Add New to Project from the context menu.
When creating a new script, there are two script types to choose from depending on your project requirements – Script Units and Script Forms. Script Units allow you to write standalone procedures and functions. Script Forms allow you to build dialogs with controls and event handlers as well as procedures and functions.
► Read about Creating & Storing Scripts in Altium Designer
There are a number of essential concepts and terms that apply to writing scripts:
The default scripting language is set to DelphiScript (
*.pas). The scripting engine itself is written in Embarcadero Delphi, and the Tool Palette panel is based on the Delphi's VCL (Visual Component Library).
► Read about Writing Scripts in Altium Designer
The Altium Designer Scripting system is composed of two main parts – the editor and the debugger. The editor offers a range of scripting code help and inspection features, and the debugger provides access to script components and debug features. The Scripting Editor Tools are a key asset when debugging scripts.
There is a range of tools in the scripting system to help in debugging scripts. These include applying multiple breakpoints in a script, using the Watch List panel to monitor the value of variables, using the bookmarks to jump around more efficiently, and using step into and over facilities to trace through scripts.
► Read about Script Editing Tools in Altium Designer
► Read about Debugging Scripts in Altium Designer
While the Altium Designer Scripting system provides the means to create sophisticated automated tasks for Altium Designer, the resulting scripts also need to be easily accessible during the design process. For example, a script created to perform a complex set of operations while editing a PCB should be readily available in the PCB Editor itself, where it can be executed with a mouse click or two.
Altium Designer caters to this need by allowing a script to be assigned to a process launcher, and thereby a command that can be assigned to a Menu, Toolbar, and Shortcut.
A script can be executed using the editor's Run command when open in the script editor. This requires the script project to be open in Altium Designer, which is not a convenient approach to accessing a script needed during the PCB design process, for example. Alternatively, the Select Item To Run dialog (File » Run Script) allows you to browse to a script on your local hard drive or a connected managed content server then run the desired process. The script remains loaded for the current session.
A more suitable method to access a frequently used script is to install the project as a Global Project from the Scripting System – Global Projects page of the Preferences dialog. In this case, the project is automatically loaded when Altium Designer starts and can be executed at any time via the File » Run Script command.
► Read about Running Scripts in Altium Designer
The visual form components available for use in Altium Designer scripts are mostly derived from Embarcadero's Visual Component Library (VCL), which is a collection of defined visual components for developing Windows applications using Delphi and C++ languages.
Developed as a visual class library, the VCL classes descend from the
TComponent object (itself a descendant from the
TObject root object) in a linear object hierarchy. Therefore a common script component, such as the
TButton object, inherits the properties, methods, and events from its ascending objects. In this case, the class hierarchy is:
TObject → TPersistent → TComponent → TControl → TWinControl → TButtonControl → TButton.
Note that the components that descend from the
TControl object are generally visual components (controls), and common components that descend from
TWinControl are mostly wrappers around the Windows API.
When creating a Form in the Altium Designer Script Editor, the components are accessed from the Tool Palette panel. Script Forms have an associated
*.DFM file that includes details of the form's configuration, its component locations, and other attributes – the file can be found in the script project's host folder. Altium Designer allows the components to be used by either DelphiScript or VBScript when designing Script Forms.
► Read about Scripting Graphical Components in Altium Designer
To provide further insight into the general aspects of the Scripting System, and the use of Delphi and X2 Object Models in scripts, two example projects are examined from a functionality perspective – a board outline copier and a netlist generating script. The Board Outline Copier and Netlister scripts are developed using the X2 Object Models to illustrate the capabilities of the scripting system in Altium Designer.
These are existing scripts available in the example script collection. The Scripts folder within the ZIP file contains subfolders that are organized according to scripting languages.
Note that a wide range of useful scripts can be found in the Altium Designer GitHub collection.
► Read about Script Example Analysis in Altium Designer
► Read about Scripting Examples Reference for Altium Designer
Scripts can be written for Altium Designer in several script languages. Note that the primary language and the most referred to in the Scripting documentation is DelphiScript — this is closely related to Embarcadero Delphi™.
► Read about Scripting Language Support in Altium Designer
Contact our corporate or local offices directly.