Skip to content

Latest commit

 

History

History
68 lines (42 loc) · 4.75 KB

HowTo_execute_scripts.md

File metadata and controls

68 lines (42 loc) · 4.75 KB

Source: https://github.com/Altium-Designer-addons/scripting-reference/blob/master/HowTo_execute_scripts.md

How to execute/run a script in Altium Designer

As an alternative to the official "running scripts" help page, we would try to guide you as simply a we can through the process of executing scripts in Altium Designer. There are (at least) 3 ways of doing this:

  1. The "Run script" command
  2. A custom menu item
  3. A custom toolbar

Understanding Altium script files

There are three types of files used by Altium Designer in the scripting system:

  • The script project file (*.PrjScr). It works as any other project files: it "groups" files together. You can define some options for the project.
  • The script "unit". It contains some programming code in one of the recognized languages (accepted languages are listed on the Altium documentation page).
  • The script "form". If your script has graphical capabilities, it probably has a "form" file having the same name as the "unit": this is the definition for a window.

In video

Thanks to Petar PERISIN, you will be able to see most of the points covered in this tutorial in a single and short video.

Solution 1: "Run script"

Running a script with AD18 Running a script with AD17

AD18 and newer: From the "File" menu, clock on "Run Script".
AD17 and older: From the "DXP" menu, click on "Run script" in the right column.

A new window appears showing a list of available script, that is:

  • Scripts made globally available in the preferences (Preferences > Scripting system > Global projects). This requires to have a project script file (*.PrjScr).
  • Scripts available in the Projects panel, either because they are part of a project or because they are open as free documents.

The list is actually a tree of this form:

  • Script project (*.PrjScr or Free documents)

Choose either a script file or a particular function and click "OK" to run it.

The script itself is visible but some functions are missing in the list ? Do these functions require some input parameters? Well, the "Run script" dialog is not able to let you start this type of functions because you cannot input anything from there, sorry.

Solution 2: New menu item

Want to have access to a script by a menu entry?

You have two possible starting points:

  • DXP > Customize (only with AD17 and older)
  • Right-click on an existing menu > Customize

Then in the section [Scripts] you get a list similar to the one from the "Run script" dialog. Drag and drop the requested script file or function in the menu bar, then customize the menu entry with a name, description, image, shortcuts, etc. When you have closed the "Customize" dialog, your menu entry becomes fully functional and must launch your script properly.

Solution 3: New toolbar

If you prefer to not put your dedicated script launchers inside the main menu, you can create your own toolbar:

  1. "DXP > Customize" or "Right-click on an existing menu > Customize"
  2. Switch to the "Toolbars" tab
  3. Click on "New", give your toolbar a name

Now that you can find your new (but empty) toolbar in the Altium Designer interface, you can follow the steps of Solution 2 to add a link to a script.

Cannot locate your freshly created toolbar? Disable then re-enable it, you would probably see it as a "flash" appearing between existing menus.