脚本实例参考
This reference covers the Altium Designer script examples available for download from Altium.
The Scripts folder within the ZIP file contains subfolders that are organized according to scripting languages. For example, DelphiScript scripts are in the DelphiScript Scripts folder. The language-specific scripts available are:
DelphiScript Examples
All DelphiScript scripts, whether they are script units or script forms, have a *.pas
extension. The DelphiScript script examples are sorted in the following script folders:
- General Scripts
- DXP Scripts
- PCB Scripts
- SCH Scripts
- Processes Scripts
- Workspace Manager Scripts
- FPGA Scripts
General folder
General scripts
\DelphiScript Scripts\General_Scripts.PRJSCR
Script Filename |
Description |
---|---|
IniFileEg |
This script demonstrates the use of |
Mandelbrot |
This script demonstrates the use of graphics to build a Mandelbrot set on a script form. |
MM |
This script demonstrates the use of the |
ShowModalEg |
This script demonstrates the use of the |
SineWave |
This script demonstrates how to generate and plot a sine wave on a script form. |
TextFileConvert |
The |
TicTac |
A Tic Tac Toe game. |
UpdateTime |
This script demonstrates the use of the |
HelloWorld
\DelphiScript Scripts\General\HelloWorld.PRJSCR
Script Filename |
Description |
---|---|
HelloWorldDialog |
A simple hello world message using the Script form. |
HelloWorld |
A simple hello world - an introduction to DelphiScript language. |
Zipper
\DelphiScript Scripts\General\Zipper.PRJSCR
Script Filename |
Description |
---|---|
ZipperForm |
This script uses the zipping API exposed in the scripting engine. This project zips up a Design project and its associated files. |
DXP folder
DXP Scripts
\DelphiScript Scripts\DXP\DXP_Scripts.PrjScr
Script Filename |
Description |
---|---|
ClientServerInterfacesReport |
This script demonstrates how to use Client interfaces and retrieves information on server installation files, window kinds, commands, and panels. |
ExtractFilesFromIntLibs |
This script demonstrates how to extract source library files from integrated library files with an |
IntLibSearchDemo |
This script demonstrates how to find footprints and 3D models in integrated library files and in PCBLIB files. |
OpenADoc |
This script demonstrates how to open a text document using Client's |
ReportIntLibData |
This script demonstrates the use of Integrated Library Manager and Model Type Manager interfaces to extract data associated with each interface. |
ReportPCBViews |
This script reports all opened PCB documents and their views in X2. |
ServerProcessReport |
This script demonstrates how to generate a report for all installed servers' processes in X2. |
SettingDocumentDirty |
This script demonstrates how to set a document dirty, so it is saved when the Save command is invoked. |
DXP Version
\DelphiScript Scripts\DXP\DXPVersion.PrjScr
Script Filename |
Description |
---|---|
DXPVersionUnit |
This script demonstrates how to find the version number of the X2 application. |
PCB folder
PCB Scripts
\DelphiScript Scripts\PCB\PCB_Scripts.PrjScr
Script Filename |
Description |
---|---|
Count_Connection_Lines |
This script demonstrates how to count connection lines (unrouted tracks) on a PCB document and displays the results on the Messages panel. |
CreateAVia |
This script demonstrates how to create a new Via object on a PCB document. |
CreateComponentOnPCB |
This script demonstrates how to create a new component on a PCB document. |
CreateFootprintInLibrary |
This script demonstrates how to create a new footprint on a Library document. |
CreatePCBObjects |
This script has various functions to create different PCB objects on a PCB document. This script uses the |
CreateRules |
This script demonstrates how to create two different rules - maximum - minimum width rule and a room definition rule (confinement constraint). |
Cycle_Pcb_Cursor_Type |
This script cycles through available cursor types on a PCB document. |
DeletePCBObjects |
This script demonstrates how to delete PCB Objects and update the Undo System properly. |
EmbeddedObjects |
This script demonstrates the use of embedded objects; that is, creates and fetches these embedded objects on a current PCB document. |
NetObjectAssign |
This script demonstrates how to assign a net property to a new object that has been placed on a PCB document. |
PadViaCacheProperties |
This script demonstrates the use of the |
PadStackInfo |
This script demonstrates how to fetch different pad stack information on a PCB document. |
QueryBoard |
This script queries the current PCB document for board settings information. |
Undo |
This script demonstrates the PCB's Undo system. Two procedures to demonstrate how the Undo system works - as one large Undo or multiple smaller Undos. |
Board Outline Copier
\DelphiScript Scripts\PCB\BoardOutline Copier\CopyBoardOutline.PrjScr
Script Filename |
Description |
---|---|
CopyBoardOutlineForm |
This script copies the board outline as tracks and arcs onto a specified layer. Layer and Width values to be specified by the user before proceeding. |
PCB Picture Creator
\DelphiScript Scripts\PCB\CreateRegionsFromBitmap\PCBPictureCreator.PrjScr
Script Filename |
Description |
---|---|
ConvertPicture |
The main form for the script. |
ConstructContourSetFromPicture |
The script that deals with creating the contour set from a loaded bitmap. |
ConstructRegionsFromContourSet |
The script that deals with creating regions from each contour set. |
Footprint Finder
\DelphiScript Scripts\PCB\FootprintFinder\FootprintFinder.PrjScr
Script Filename |
Description |
---|---|
FindFootprintUnit |
Look for a footprint in a PCB library using PCB API. |
From Tos Generator
\DelphiScript Scripts\PCB\FromTosGenerator\FromTosGenerator.PrjScr
Script Filename |
Description |
---|---|
CreateInterComponentFromTos |
A script for asking the user to select two components then it connects pads with same net assignments. Limitations of this script: You need to move the cursor away from a component to exit. All nets need to be rebuilt manually after this script is run. |
formFormTos |
Script Form for this project. |
Hole Size Editor
\DelphiScript Scripts\PCB\Hole Size Editor\Hole Size Editor.PrjScr
Script Filename |
Description |
---|---|
HSForm |
This is the Specific Hole Size Editor dialog to change one of the hole sizes. |
HSEditForm |
This is the main script for the Hole Size editor. |
Customsort |
This customsort script contains sorting routines for the Hole Size Editor script. |
Mill Exporter
\DelphiScript Scripts\PCB\Mill Exporter\MillExporter.PrjScr
Script Filename |
Description |
---|---|
MillExporter |
A Project file. Export a PCB design into a format that can be milled by a CNC Milling machine. Currently, only Roland RML milling language is supported. |
MillExporter |
This unit converts a Board Outline of the PCB document to a polygon so that data can be generated for the PCB document and be milled by a CNC milling machine. |
MMExportDlg |
This unit controls the settings for exporting a PCB document to be routed on a milling machine. |
MMSetup |
Setup the default values for a milling machine to be used by MillExporter in an INI text file. |
PCB Class Generator
\Delphiscript Scripts\PCB\PCB_Class_Generator.PrjScr
Script Filename |
Description |
---|---|
PCB_Class_Generator.PrjScr |
A PCB Class Generator Project file. |
PCB_Class_Generator_Form.dfm |
This script form is associated with the |
PCB_Class_Generator_Form.pas |
This script adds nets of selected PCB objects into a net class and has a corresponding script form. |
PCB Iterators
\DelphiScript Scripts\PCB\PCB Iterators\PCB Iterators.PrjScr
Script Filename |
Description |
---|---|
Count_pads |
This script counts the number of pads on a current PCB document. |
CountTracksInComponent |
This script counts tracks of five different components on a current PCB document. |
IterateComponentBodies |
This script fetches component bodies from the current PCB document. |
IterateNets |
This script demonstrates how to iterate for Nets of the current PCB document. |
IteratePolygons |
This script iterates Polygons from the current PCB document. |
IterateRegions |
This script iterates regions from the current PCB document. |
LibraryIterator |
This script demonstrates the use of the library iterator and displays the number of child objects (primitives of a footprint) for each footprint found in a PCB library. |
SpatialIterator |
This script demonstrates the use of the |
PCB Layers
\DelphiScript Scripts\PCB\PCB Layers\PCB_Layers.PrjScr
Script Filename |
Description |
---|---|
Layers_Info |
This script fetches Layers information for the layer stack of the PCB. |
QueryLayerPairs |
This script queries the current PCB document for PCB Layer pairs. |
QueryLayersOfMechType |
This script queries the current PCB document for mechanical layers. |
QueryLayerStack |
This script queries the Layer Stack of the current PCB document. |
QueryMechLayers |
This script queries mechanical layers of the current PCB document. |
QueryUsedLayers |
This script queries the current PCB document for layers that are used. |
RebuildInternalAndSplitPlanes |
This script forces a rebuild of the internal and split planes for the PCB. |
Toggle_Connect_layer_display |
The script toggles the visibility of the connect layer on the current PCB. |
ValidateLayerStack |
This script validates the layer stack and reports a warning if the stack is invalid. |
PCB Logo Creator
\DelphiScript Scripts\PCB\PCB Logo Creator\PCBLogoCreator.PrjScr
Script Filename |
Description |
---|---|
Converter |
Script form as the dialog that prompts the user to load a monochrome image and then choose thickness of tracks, whether to mirror or not etc. |
PCB Objects Mover
\DelphiScript Scripts\PCB\PCBObjectsMover\PCBObjectsMover.PrjScr
Script Filename |
Description |
---|---|
OffSetObjectsForm |
Form for the project. |
OffSetObjects |
Demonstrate the use of |
PCB Outputs
\DelphiScript Scripts\PCB\PCBOutputs\PCBOutputsProject.PrjScr
Script Filename |
Description |
---|---|
PCBOutputGenerator |
This unit does the following:
|
Violations |
Fetch existing violation objects and generate a report outlining different violations. |
GetObjectClasses |
Object Classes Reporter Script Form. You choose which object class before generating a list of object classes of a particular kind as a text file. |
PCB Rules
\DelphiScript Scripts\PCB\PCB Rules\PCB Rules.PrjScr
Script Filename |
Description |
---|---|
IterateRules |
This script fetches existing rules for the current PCB and generates a text report on rules used, their IDs, and their names. |
ModifyWidthRules |
This script modifies existing Width Constraints that have a Min, Favored, and Max Widths of less than 20 mils in width and updates them to 10 mils in width. |
PCBLIB Outputs
\DelphiScript Scripts\PCB\PCBLIB Outputs\FootprintInfo.PrjScr
Script Filename |
Description |
---|---|
FootprintInfoReport |
This script generates a CSV formatted report of all footprints with their footprint names, heights, and descriptions. |
Swap Or Rotate Components
\DelphiScript Scripts\PCB\SwapOrRotateComponents\SwapOrRotateComponents.PrjScr
Script Filename |
Description |
---|---|
SwapComponentsUnit |
Swaps two similar components or rotate a component. |
Unique Object Checker
\DelphiScript Scripts\PCB\Unique Object Checker\UniqueObjectChecker.PrjScr
Script Filename |
Description |
---|---|
Common |
Common routines to use for the project. |
ObjectChecker |
Checks for duplicated Nets and Components on a current PCB document. |
UnRoute Net Class
\DelphiScript Scripts\PCB\UnRoute Net Class\UnRoute Net Class.PrjScr
Script Filename |
Description |
---|---|
Form_ChooseNetClass |
This script form prompts you to choose which net class so that the objects belonging to this net class can be unrouted. |
Values Checker
\DelphiScript Scripts\PCB\Values Checker\ValuesChecker.PrjScr
Script Filename |
Description |
---|---|
ValuesCheckerUnit |
This Script checks whether objects on the PCB document contain valid values before generating an output for loading in the CAM Editor. |
PCBAPI functions |
Script unit that contains functions to be used for the Values Checker dialog. |
SCH folder
Schematic scripts.
Sch Scripts
\DelphiScript Scripts\SCH\Sch_Scripts.PrjScr
Script Filename |
Description |
---|---|
AddModelToComponentScript |
This script demonstrates how to add a simulation model to a 555 component. This is done by adding a |
CountPorts |
This script uses an iterator to count ports. |
CreateComponent_on_Sch |
This script demonstrates how to place a component on a schematic document. |
CreateSchObjects |
This script creates Schematic Objects two ways;
This script uses the RobotManager interface to send schematic messages. |
DeleteSchObjects |
The script demonstrates how to delete Schematic Objects and Updating the Undo System by using the |
FetchParameters |
This script has two procedures. The first procedure fetches system parameters (document parameters) and the second one shows how to fetch parameters of a component. |
IterateSchSheets |
This script shows how to fetch open schematic sheet handles in Altium Designer. |
ModelsOfaComponent |
This script obtains models for each component on a schematic document and generates a report with a list of components and their associated (linked) models. |
ModifySchObjects |
This script shows how to fetch and modify Schematic Objects and update the undo system by using the |
MoveParameters |
This script shows how to move parameters graphically of a parent object such as a component using the |
ParentChild_Iterators |
This script uses an iterator to look for sheet symbols and then within each sheet symbol, use the sheet symbol's iterator to look for sheet entries. |
PlaceAPort |
This simple script shows how to place a new port object on a Schematic sheet. |
PlaceSchObjects |
This simple script places different objects on a schematic sheet. |
ReplaceSchObjects |
This script replaces cross sheet connectors with port objects and transferring net information automatically. |
SchDocsRenamer |
This script utilizes the |
SimModelsOfComponents |
This script fetches Simulation models and their relevant parameters for each component and then generates a text report on these models and parameters. |
UndoRedo |
This script demonstrates how to use the Undo system when a schematic document is being modified. |
UsingaSpatialIterator |
This script demonstrates the use of a spatial iterator to conduct a search within a defined region. |
UsingSchInterfaces |
This script demonstrates the Schematic interfaces. |
UsingWSMInterfaces |
This script demonstrates the WorkSpace Manager interfaces. |
SchLib Scripts
\DelphiScript Scripts\SCH\SchLib_Scripts.Prjscr
Script Filename |
Description |
---|---|
CheckPins |
This script checks for valid pins of symbols in a library. |
CreateComp_in_Lib |
This script demonstrates how to create a new symbol in the library. |
CompLibReader |
This script uses the |
LibIterator |
This script shows how to iterate through a schematic library and fetch symbols. |
ParametersOfSymbolsInALibrary |
This script shows how to fetch parameters of symbols in a schematic library using an iterator. |
SymbolPrimsIterator |
This script shows how to fetch primitives of a symbol. |
Sch Translator
\DelphiScript Scripts\SCH\Circad Translator\Sch Translator.PrjScr
Script Filename |
Description |
---|---|
StringUtils |
This unit deals with the data types. |
DesignSettings |
This unit deals with reading the Settings table for the CirCad data. |
Log |
This unit deals with the generation of a log file with results. |
ImportUtils |
This unit deals with the translation of CirCad data for Altium Designer. |
InputForm |
This unit deals with the translator dialog. |
Test |
This standalone unit deals with testing of CirCad data. |
Component Replacer
\DelphiScript Scripts\SCH\CompReplace\ComponentReplacer.PrjScr
Script Filename |
Description |
---|---|
ReplaceSelectedComponent |
Replaces a selected component on the schematic with a 2N3904 symbol from the |
Connectivity
\DelphiScript Scripts\SCH\Connectivity\NetInfoPrj.PrjScr
Script Filename |
Description |
---|---|
Connectivity |
This unit generates Parameters with Pin Net Info for pins of components from a focused schematic or selected schematics of a PCB Project. |
DefnForm |
The script form to handle User input. |
Font Editor
\DelphiScript Scripts\SCH\Font Editor\Fonts Editor.PrjScr
Script Filename |
Description |
---|---|
FontsDialog |
This script demonstrates the use of the Schematic Font Manager interface. |
Import Pins
\DelphiScript Scripts\SCH\Import Pins\ImportPins.PrjScr
Script Filename |
Description |
---|---|
ImportPinsForm |
The
|
ChangeMappingForm |
The Change Mapping dialog to map fields from a |
ConvUtils |
This script has the |
PinData.CSV |
This file contains pin information that is used for the |
Update Footprint Locations
\DelphiScript Scripts\SCH\UpdateFootprintLocations\FootprintPathUpdater.PrjScr
Script Filename |
Description |
---|---|
UpdateFootprintPathsOfComps |
A Schematic Component has a Footprint (PCB Model) property and its Library Path property. There are situations when components have the same footprint name but come from different libraries. |
User Defined Parameters
\DelphiScript Scripts\SCH\UserDefinedParameters\UserDefinedCompParameters.PrjScr
Script Filename |
Description |
---|---|
ComponentParameters |
This script demonstrates how to create, modify and delete user-defined parameters for components in schematic designs of a hierarchical project. |
Processes folder
Process Scripts
\DelphiScript Scripts\Processes\Process_Scripts.PrjScr
Script Filename |
Description |
---|---|
Clrins1 |
This script demonstrates how to delete objects within an area defined by the user. |
Clrins2 |
This script demonstrates how to delete objects within an area defined by the user. The user is prompted before objects are cleared. |
CirWiz |
This script form generates a simple filter circuit and place on a schematic sheet. |
PCBColor |
This script demonstrates how to change PCB Colors for a PCB document using the |
PCBLayer |
This script demonstrates how to toggle the visibility of PCB Layers using the |
PlacePCBPolygon |
This script places a new PCB polygon object on a PCB document using the |
PlaceSchPort |
This script places a new Schematic Port object on a Schematic document using the |
PublishToPDFScript |
This script publishes from a current project's OutJob document to a PDF and bypasses the Publish to PDF Settings dialog. |
QuikCopy |
This script demonstrates how to select objects, then copy and paste them using |
RunCommonDialog |
This script demonstrates how to invoke the Client module's Common dialog and fetch parameters. |
ShowNetlist |
This script demonstrates how easy it is to generate a report using WorkspaceManager's |
SimpleExample |
This script demonstrates the use of |
WSM folder
Workspace Manager scripts.
WSM Scripts
\DelphiScript Scripts\WSM\WSM_Scripts.PrjScr
Script Filename |
Description |
---|---|
AddDocToProject |
This script demonstrates how to insert a schematic sheet in a new PCB Project. There needs to be a |
Netlister |
This script demonstrates how to generate a specific PackingList format file for a Schematic project. |
ProjectReporter |
This script finds currently open projects including Free projects in X2. A free project is a group of documents that are not related to any project. |
UsingMessagePanel |
This script demonstrates how to insert text messages in the Messages panel in Altium Designer. This is a useful debugging tool. |
Netlister
\DelphiScript Scripts\WSM\ProtelNetlister\ScripterProtelNetlist.PrjScr
Script Filename |
Description |
---|---|
ScripterProtelNetlist |
This script demonstrates the use of WorkSpace Manager interfaces to generate a Protel type Netlist. The Netlist file is generated in |
FPGA folder
Swap IDs Updater
\Delphiscript Scripts\FPGA\SwapIdsUpdater\FPGASwapIds_Project1.PrjScr
Script Filename | Description |
---|---|
UpdateConstraintUnit | This script allows you to change the swap group Ids for the pins of an FPGA component on the PCB document, without invoking the FPGA Pin Swap Manager. |
CheckNameValueUnit | Name checking and processing script. |
JScript Examples
Within the Script collection (download), the JScript examples can be found in the Scripts\JScript Scripts\
folder. The JScript scripts have a *.js
extension.
Script Filename |
Description |
---|---|
AddDocToProject |
This script demonstrates how to insert a sheet in a PCB Project. There needs to be a |
BuiltInFunctions |
This script demonstrates how to use built-in date and math objects and display the results using the |
CopyBoardOutlineForm |
This script copies the board outline as tracks and arcs onto a specified layer. |
GetScriptEngineInfo |
Retrieves the Microsoft Scripting Engine version number. |
HelloWorld |
A simple hello world - an introduction to JScript language. |
ParentChild_Iterators |
This script uses an iterator to look for sheet symbols and then within each sheet symbol, use the sheet symbol's iterator to look for sheet entries. |
ServerProcessReport |
This script demonstrates how to generate a report for all installed servers' processes in Altium Designer. |
SineWave |
This script demonstrates how to plot a sine wave in a script form. |
ViaCreation |
This script demonstrates how to create a new Via object on a PCB. |
VBScript Examples
Within the Script collection (download), the VBScript examples can be found in the Scripts\VBScript Scripts\
folder. The VBScript scripts have a *.vbs
extension.
Script Filename |
Description |
---|---|
AddDocToProject |
This script demonstrates how to insert a schematic sheet in a new PCB Project. There needs to be a |
CopyBoardOutline |
This script copies the board outline as tracks and arcs onto a specified layer. Layer and Width values to be specified by the user before proceeding. Uses PCB Object Model. |
GetScriptEngineInfo |
Retrieves the Microsoft Scripting Engine version number. |
HelloWorld |
A simple hello world - an introduction to VBScript language. |
ParentChild_Iterators |
This script uses an iterator to look for sheet symbols and then within each sheet symbol, use the sheet symbol's iterator to look for sheet entries. Uses Schematic Object Model. |
ServerProcessReport |
This script demonstrates how to generate a report for all installed servers' processes in Altium Designer. |
SineWave |
This script demonstrates how to generate and plot a sine wave on a script form. Uses Components and a Script form. |
ViaCreation |
This script demonstrates how to create a new Via object on a PCB document. Uses PCB Object model. |