Script

Now reading version 18.1. For the latest, read: Script for version 22
 

Parent page: Server Items

Altium Designer, in conjunction with your managed content server, caters for the ability to create and manage Script Items in that Server. Such Items are created directly within the Server, with the relevant script project (*PrjScr) uploaded to a revision of a target item. Once a Script Item has been created (and data released into a revision of it), and its lifecycle state set to a level that the organization views as ready for use at the design level, it can be reused in future board-level design projects.

Ranging from simple utility scripts to those performing complex source operations, Scripts can be both a convenient and powerful way of adding functionality to Altium Designer. In Altium Designer, these managed Scripts can be opened directly from the managed content server, loaded as permanently available projects, and used in custom menu commands.

In addition, and when using an Altium NEXUS Server as your managed content server, a managed Script Item can be used indirectly as part of a revision of a managed Designer Preferences Item in one or more defined Environment Configurations. An environment configuration is used to constrain a designer's Altium Designer working environment to only use company-ratified design elements. Environment configurations are defined and stored within the Team Configuration Center - a service provided through the Altium NEXUS Server installation, and the facilitator of this concept of Environment Configuration Management.

In addition, and when using an Altium NEXUS Server as your managed content server, a managed Script Item can be used indirectly as part of a revision of a managed Designer Preferences Item in one or more defined Environment Configurations. An environment configuration is used to constrain a designer's Altium NEXUS working environment to only use company-ratified design elements. Environment configurations are defined and stored within the Team Configuration Center - a service provided through the Altium NEXUS Server installation, and the facilitator of this concept of Environment Configuration Management.

Folder Type

When creating the folder in which to store a Script Item, you can specify the folder's type. This has no bearing on the content of the folder - uploading will always result in a Script Item. It simply provides a visual 'clue' as to what is stored in a folder and can be beneficial when browsing a Server for particular content. To nominate a folder's use as a container for Script Items, set its Folder Type as Scripts, when defining the folder properties in the Edit Folder dialog.

Specifying the folder type - its intended use - gives a visual indication of the content of that folder when browsing the Server!
Specifying the folder type - its intended use - gives a visual indication of the content of that folder when browsing the Server!

Item Type

When creating the target Script Item in which to store your script project, ensure that its Content Type is set to Script in the Create New Item dialog. If you are creating the Item in a Scripts type folder, this Item type will be available from the right-click context menu when creating the Item.

Creating a Script Item within a Scripts folder - the correct Content Type is available on the context menu.
Creating a Script Item within a Scripts folder - the correct Content Type is available on the context menu.

Uploading a Script Project

So far, we've discussed the support for a Script Item in the Server, in terms of related folder and item types. Uploading a script project into the revision of such an item can be performed by right-clicking on the required Script Item in the Explorer panel, and choosing the Upload command from the context menu. The standard Windows Open dialog will appear, with which to browse to the required script project file (*.PrjScr).

If the Item has no planned revision, upload will be to the next planned revision, created on-the-fly as part of the upload process.

Specifying the script project file to be uploaded to the target Script Item.Specifying the script project file to be uploaded to the target Script Item.

With the desired file selected, proceed with the upload by clicking the Open button. The project file, along with all files in the same folder, are uploaded to the revision, and will be available in the Details aspect view for that revision, in the Explorer panel.

The uploaded project, along with all files in the same folder, are listed in the Details aspect view for the revision of the Script Item.The uploaded project, along with all files in the same folder, are listed in the Details aspect view for the revision of the Script Item.

Drag and Drop from Windows Explorer

A script project can also be uploaded into a new Script Item by dragging the selected script project file and related source files from a source folder in your Windows Explorer, and dropping into the required folder in the Explorer panel. The Create New Item dialog will appear, with the dragged files listed in the Sources region. The Name of the item will be the file names, including extension (entries will be separated by a semi-colon). The Description will be in the format Uploaded from <FileNameandPath>, Size <FileSize>, Created on <FileCreationDate> (entries will be separated by a semi-colon). Change these as required. The Item ID will be in accordance with the Item Naming scheme defined at the folder level. If the folder has no naming scheme defined, naming will follow the $CONTENT_TYPE_CODE-001-{0000} scheme.

Uploading a script project and related files to the initial revision of a newly-created Script Item, using the drag and drop method.Uploading a script project and related files to the initial revision of a newly-created Script Item, using the drag and drop method.

Reusing a Managed Script Item

Related page: Controlling Access to Server Content

Once a script project has been uploaded to a managed content server, and its lifecycle state set to a level that the organization views as ready for use at the design level, that script can be reused in future board-level design projects.

When you are signed in to your managed content server, you are free to manually reuse the revisions of any Script Items that have been shared with you.

If you do not sign in to your managed content server you can still work with Altium Designer (under your valid Altium Designer License), but you will not be able to access your organization's managed content server, or any other services it provides. You will therefore not be able to reuse any managed Script Items. You will only be able to use file-based scripts defined locally.

Running a Managed Script

To run a managed accessible script directly in Altium Designer (File » Run Script), choose the Browse » From server command in the Select Item To Run dialog. The managed Script Project selected in the following Choose Item dialog (essentially an incarnation of the Explorer panel) will be opened from the Server in the Select Item To Run dialog, where it can be Run in the usual way.

Choose to run a script from a managed content server source, rather than a local source, by using the From server command in the Select Item to Run dialog.Choose to run a script from a managed content server source, rather than a local source, by using the From server command in the Select Item to Run dialog.

Installing a Managed Script

Altium Designer allows any number of Script Projects to be installed on a permanent basis, so their functionality becomes available at all times, for all Altium Designer sessions. This feature is available from the Scripting System - Global Projects page of Altium Designer's Preferences dialog (click on the  control at the top-right of the workspace).

To install a Script Project from your managed content server, click the  button and choose the Install from server command from the associated menu. Select the desired managed Script Item from the subsequent Choose Item dialog (essentially an incarnation of the Explorer panel), and click OK to install the Script Project.

Installed Scripts are always available in Altium Designer, and are configured on the Scripting System - Global Projects page of the Preferences dialog.Installed Scripts are always available in Altium Designer, and are configured on the Scripting System - Global Projects page of the Preferences dialog.

The installed Script Project will be available to Altium Designer whenever a user is signed in to the managed content server with suitable credentials. Note that the installed Script Project is listed by its location or 'path' within the Server's folder structure, and the ID of the Script Item containing the script project data.

A Managed Script installed from a managed content server is listed by its Server path and Item ID.A Managed Script installed from a managed content server is listed by its Server path and Item ID.

The Server reference links created in the Preferences by an installed Script Project are retained, and therefore will be included if the current Preferences set is also released to the Server. A revision of the resulting managed Designer Preferences Item, if reused, will therefore automatically provide the linked Managed Script.

Creating a Managed Script Command

In Altium Designer, a Script (either locally or Server-sourced) can be applied to a menu item with a number of simple steps. This relies on the permanent availability of that Script, which must be installed through the Scripting Preferences (as detailed previously).

A custom Command is created from an installed Script using the Customize feature - make the editor in which you wish to use the script active (open a document of the required type), then double-click to the right of the main menus to access the Customizing dialog. Once there, click the  button to create a new command, the properties of which are defined through the Edit Command dialog.

Access customization to create a new command that will run your intended managed script.Access customization to create a new command that will run your intended managed script.

This involves the definition of a new Action based on the Script Process (ScriptingSystem:RunScript) and Parameters. The command Parameters define the full path to the Script and its target Procedure, and are in the form: ProjectName|ProcName>Process.  So for a typical locally-stored Script, this might be:

ProjectName=C:\Test Designs\Altium Scripts\HelloWorld.PRJSCR|ProcName=HelloWorld.pas>HelloWorld

For a managed Script Project hosted in a managed content server however, the path, and therefore the command’s Parameters entry, must point to the correct Server location - which is based on the Script Item’s GUID reference. So this reference link must be obtained before attempting to create the new Script command entry.

To capture the correct Parameters for a Script installed from the Server, open the Select Item To Run dialog (File » Run Script), right-click on the desired procedure in the Script and choose the Copy script parameters command from the context menu. This will copy the entire path, process name and procedure to the clipboard.

Select the required process/procedure in the managed script project, then copy the script's parameters.Select the required process/procedure in the managed script project, then copy the script's parameters.

Back in the Edit Command dialog, paste the copied script parameters into the Parameters field, then complete the other fields (Caption, Image, Shortcuts) as required.

Paste the copied managed Script parameters in the Parameters field, then proceed as you would when creating a command from a locally-sourced Script.Paste the copied managed Script parameters in the Parameters field, then proceed as you would when creating a command from a locally-sourced Script.

From the Customizing dialog, the completed script command can be dragged to a suitable Altium Designer Toolbar or Menu, and run as needed.

Note that since the command's Script is sourced from your managed content server, it will be only available when the user has signed in to that Server with the correct credentials.

A menu command created from a managed Script is functional when the user is signed in to its host Server.A menu command created from a managed Script is functional when the user is signed in to its host Server.

A menu command created from a managed Script is functional when the user is signed in to its host Server.A menu command created from a managed Script is functional when the user is signed in to its host Server.

Reuse as Part of an Environment Configuration

When using an Altium NEXUS Server as your managed content server, a managed Script Item can be used indirectly as part of a revision of a managed Designer Preferences Item - when installed as part of those released preferences, through the Scripting System - Global Projects page of the Preferences dialog - in one or more defined Environment Configurations. An environment configuration is used to constrain a designer's Altium Designer working environment to only use company-ratified design elements. Environment configurations are defined and stored within the Team Configuration Center - a service provided through the Altium NEXUS Server installation. Once you have signed in to the Altium NEXUS Server, and chosen (if applicable) from the selection of environment configurations available to you, Altium Designer will be configured, with respect to use of preferences. If the chosen environment configuration has a defined Designer Preferences Item revision, then that is applied straight away. If the chosen environment configuration applicable to you does not have a Designer Preferences Item revision specified, then preferences will remain manually definable. In other words, you are free to manually reuse a revision of a managed Designer Preferences Item, or use a locally saved preferences file. For more information, see Environment Configuration Management.

Reuse as Part of an Environment Configuration

When using an Altium NEXUS Server as your managed content server, a managed Script Item can be used indirectly as part of a revision of a managed Designer Preferences Item - when installed as part of those released preferences, through the Scripting System - Global Projects page of the Preferences dialog - in one or more defined Environment Configurations. An environment configuration is used to constrain a designer's Altium NEXUS working environment to only use company-ratified design elements. Environment configurations are defined and stored within the Team Configuration Center - a service provided through the Altium NEXUS Server installation. Once you have signed in to the Altium NEXUS Server, and chosen (if applicable) from the selection of environment configurations available to you, Altium NEXUS will be configured, with respect to use of preferences. If the chosen environment configuration has a defined Designer Preferences Item revision, then that is applied straight away. If the chosen environment configuration applicable to you does not have a Designer Preferences Item revision specified, then preferences will remain manually definable. In other words, you are free to manually reuse a revision of a managed Designer Preferences Item, or use a locally saved preferences file. For more information, see Environment Configuration Management.

Re-releasing a Script Item

At any stage, you can come back to any revision of a Script Item in the Server, and edit it directly. Right-click on the revision and choose the Edit command from the context menu. This will open that revision in Altium Designer where it can be edited as required, then released back to the Server as the next revision using the Release to server command (shortcut: Alt+Ctrl+S) - available from the right-click context menu associated with the entry for the project in the Projects panel.

Right-clicking on the top-level entry for an Item itself, will edit the latest revision of that Item.

Accessing the command to launch direct editing of an existing revision of a Script Item.Accessing the command to launch direct editing of an existing revision of a Script Item.

Downloading Files

Download the files (project and associated source) stored in a revision of a Script Item, by right-clicking on that revision and choosing the Operations » Download command from the context menu. The file will be downloaded into a sub-folder under the chosen directory, named using the Item Revision ID. The file can be found in the Released folder therein.

Access the Download command from the top-level entry for a Script Item itself, to download the files stored in the latest revision of that Item.
Click the Explore button in the Download from Vault dialog, to quickly explore to the download folder.

 

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

The features available depend on your Altium product access level. Compare features included in the various levels of Altium Designer Software Subscription and functionality delivered through applications provided by the Altium 365 platform.

If you don’t see a discussed feature in your software, contact Altium Sales to find out more.

Content