スクリプト例

現在、バージョン 19. をご覧頂いています。最新情報については、バージョン スクリプト例 の 25 をご覧ください。
 

Parent page: Automating Design Tasks with Scripting

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:

Due to progressive updates to the Altium Designer API, and therefore the scripting system Interfaces and their methods and properties, some legacy script examples may not work as originally intended. Nevertheless, all of the scripts in the script examples collection are a useful resource and can be used as reference information for creating your own scripts.
Note that a wide range of useful scripts can be found in the Altium Designer GitHub collection.

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 folder

General scripts

\DelphiScript Scripts\General_Scripts.PRJSCR

Script Filename

Description

IniFileEg

This script demonstrates the use of TIniFile object and the Read/Write methods.

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 TMediaPlayer component. The Protel.avi file is needed for this MM script.

ShowModalEg

This script demonstrates the use of the ShowModal property for the script form.

SineWave

This script demonstrates how to generate and plot a sine wave on a script form.

TextFileConvert

The input.txt file is provided for demo purposes.

TicTac

A Tic Tac Toe game.

UpdateTime

This script demonstrates the use of the TTimer component and the Time function.

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 INTLIB extension.

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 OpenDocument method.

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 SendMessageToRobots method to send PCB messages.

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 TPadCache record and the GetObjectAtCursor method for Pad and Via Objects. Load PadViaExamples.PcbDoc from the \DelphiScript Scripts\PCB folder before running the script.

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 script.

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 ChooseRectangleByCorners method and the spatial iterator. Selects free primitives only on the focused PCB.

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 ChooseRectangleByCorners method and the spatial iterator. Moves the objects within the defined boundary on the PCB.

PCB Outputs

\DelphiScript Scripts\PCB\PCBOutputs\PCBOutputsProject.PrjScr

Script Filename

Description

PCBOutputGenerator

This unit does the following:

  1. LookForFiducials.
  2. Check Board Outline Dimensions.
  3. Generate an output (PickPlace and BOM).

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.
The script asks the user to select two components then have their positions swapped, or if the same component is selected twice, have it rotated.
Limitations of this script: You need to move the cursor away from a component to exit.

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 555.ckt file to this component.

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;

  1. the first procedure places two ports and only one undo will remove both
  2. the second procedure places two ports and need two undos to remove both.

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 RobotManager interface to send schematic messages.

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 RobotManager interface to send schematic messages.

MoveParameters

This script shows how to move parameters graphically of a parent object such as a component using the Location property and its get/set methods.

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 FileCopy function from the Delphi Windows unit to copy existing files with different filenames.

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 CreateLibCompInfoReader method to extract component data of a specified Schematic Library.

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 Miscellaneous Devices.IntLib library.

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 ImportPinsForm is the main form. You need a CSV file that contains data for pins to import and create new Pins onto a SchLib document.
To use the script:

  1. Execute the ImportPins procedure and the Pins Importer dialog appears.
  2. Click the browse button to load in the CSV file of schematic pins data.
  3. Click on the Update Mapping button to refresh the links between text fields and pin properties, then click the Import button to generate a list of different pins on an Sch library page.

ChangeMappingForm

The Change Mapping dialog to map fields from a CSV text file. This script is used by the main Import Pin dialog.

ConvUtils

This script has the Conversion of Schematic Types To Strings and Vice Versa routines.

PinData.CSV

This file contains pin information that is used for the ImportPins script.

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.
This script allows you to choose a footprint name from the currently open schematic and then choose one of available footprint locations. The locations are based on existing components footprint' locations. Then when the dialog is closed, all the components that have the same footprint name have their locations updated with the specified location.
Make sure you have libraries installed for the Schematic Components so that footprint library locations (paths) can appear.

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 SetupPreferences process.

PCBLayer

This script demonstrates how to toggle the visibility of PCB Layers using the DocumentPreference process.

PlacePCBPolygon

This script places a new PCB polygon object on a PCB document using the PlacePolygonPlane process.

PlaceSchPort

This script places a new Schematic Port object on a Schematic document using the PlacePort process.

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 ToggleSelection, Deselect, Paste and Copy processes.

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 GenerateReport process.

SimpleExample

This script demonstrates the use of AddIntegerParameter and GetIntegerParameter functions.

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 sheet1.schdoc file in C:\ folder first.

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 Generated folder for the current project on the Projects panel.
To run this script, you need to have the ScripterProtelNetlist.PRJSCR project opened, then call the Run script command from the File menu and select the ScripterProtelNetlist.pas file from the Select Item to Run dialog.
The script will then generate a netlist for the current project, so make sure the project is focused before the script is run.

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.

EnableBasic Script Examples

Within the Script collection (download), the EnableBasic examples can be found in the Scripts\EnableBasic\ folder. The EnableBasic scripts have a *.bas extension.

Script Filename

Description

CirWiz

The script demonstrates the use of processes in placing/connecting parts together.

Clrins1

Delete objects within an area defined by the user.

Clrins2

Delete objects within an area defined by the user. Confirm before deleting.

PcbColor

This script demonstrates the use of processes in changing PCB Colors.

PcbLayer

This script demonstrates the use of processes in changing PCB Layers.

PlaceSchPort

Place Schematic Port Object with the PlacePort process.

Quikcopy

This script demonstrates how to select objects and then Copy and Paste.

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 sheet1.schdoc file in C:\ folder first.

BuiltInFunctions

This script demonstrates how to use built-in date and math objects and display the results using the ShowMessage function.

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.

TCL Script Examples

No examples at present.

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 sheet1.schdoc file in C:\ folder first.

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.

Query Script Examples

Within the Script collection (download), the Query examples can be found in the Scripts\Query Scripts\ folder.

Script Filename

Description

SimpleExpression

Demonstration of a query script to execute in the Filter panel's query window for a PCB document. Query scripts need to be installed in the Installed Projects list from the Scripting System – Global Projects page of the Preferences dialog.

If you find an issue, select the text/image and pressCtrl + Enterto send us your feedback.
注記

利用できる機能は、Altium 製品のアクセスレベルによって異なります。Altium Designer ソフトウェア サブスクリプション の様々なレベルに含まれる機能と、Altium 365 プラットフォーム で提供されるアプリケーションを通じて提供される機能を比較してください。

ソフトウェアの機能が見つからない場合は、Altium の営業担当者に連絡して 詳細を確認してください。

Content