Script

This documentation page references Altium NEXUS/NEXUS Client (part of the deployed NEXUS solution), which has been discontinued. All your PCB design, data management and collaboration needs can now be delivered by Altium Designer and a connected Altium 365 Workspace. Check out the FAQs page for more information.

 

Parent page: Workspace Content Types

Altium NEXUS, in conjunction with your connected Workspace, caters for the ability to create and manage scripts (Script Items) in that Workspace. Such scripts are created directly within the Workspace, with the relevant script project (*.PrjScr) uploaded to a revision of a target Item. Once a script has been created (and data saved into a revision of it), 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 NEXUS. In Altium NEXUS, these scripts can be opened directly from the Workspace, loaded as permanently available projects, and used in custom menu commands.

In addition, a Script Item can be used indirectly as part of a revision of a Design 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 Workspace, and the facilitator of this concept of Environment Configuration Management. For more information, see Environment Configuration Management (for an Altium 365 Workspace or a NEXUS Server Workspace).

Folder Type

When creating the folder in which to store scripts, 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 Workspace for particular content. To nominate a folder's use as a container for scripts, 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 Workspace.
Specifying the folder type – its intended use – gives a visual indication of the content of that folder when browsing the Workspace.

Content 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 content type will be available from the right-click context menu when creating the Item.

Creating a script within a Scripts folder – the correct Content Type is available on the context menu.
Creating a script 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 in the Workspace, in terms of related folder and content types. Uploading a script project into the revision of a Script 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 on the Details aspect view tab for that revision, in the Explorer panel.

The uploaded project, along with all files in the same folder, are listed on the Details aspect view tab for the revision of the Script Item.
The uploaded project, along with all files in the same folder, are listed on the Details aspect view tab 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-{000000} 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 Script

Related page: Controlling Access to Workspace Content

Once a script project has been uploaded to a Workspace, 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 connected to your Workspace, you are free to manually reuse the revisions of any Script Items that have been shared with you.

If you do not connect to your Workspace you can still work with Altium NEXUS (under your valid Altium NEXUS license), but you will not be able to access that Workspace, or any other services it provides. You will therefore not be able to reuse any Workspace-based scripts. You will only be able to use file-based scripts defined locally.

Running a Workspace Script

To run a script uploaded to your connected Workspace directly in Altium NEXUS:

  1. Choose the File » Run Script command from the main menus.
  2. In the Select Item To Run dialog, click the button and choose the From server entry.
  3. Browse to and select, the required revision of the Script Item in the Choose Item dialog (essentially an incarnation of the Explorer panel). Then click OK.
  4. The Workspace script project will be opened in the Select Item To Run dialog, where it can be Run in the usual way.

Choose to run a script from a Workspace 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 Workspace source, rather than a local source, by using the From server command in the Select Item to Run dialog.

Installing a Workspace Script

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

To install a script project from your Workspace, click the button and choose the Install from server command from the associated menu. Select the desired Workspace-based script 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 NEXUS, and are configured on the Scripting System – Global Projects page of the Preferences dialog.
Installed scripts are always available in Altium NEXUS, and are configured on the Scripting System – Global Projects page of the Preferences dialog.

The installed script project will be available to Altium NEXUS whenever a user is connected to the Workspace. Note that the installed script project is listed by its location or 'path' within the Workspace's folder structure, and the ID of the Script Item containing the script project data.

A script installed from a Workspace is listed by its Workspace path and Item ID.
A script installed from a Workspace is listed by its Workspace path and Item ID.

The Workspace reference links created in the Preferences by an installed Workspace script project are retained, and therefore will be included if the current Preferences set is also released to the Workspace. A revision of the resulting Design Preferences Item, if reused, will therefore automatically provide the linked Workspace script.

Creating a Workspace Script Command

In Altium NEXUS, a script (either locally or Workspace-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 Workspace script.
Access customization to create a new command that will run your intended Workspace 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:\Workspace Testing\Altium Scripts\HelloWorld.PRJSCR|ProcName=HelloWorld.pas>HelloWorld

For a script project hosted in a Workspace however, the path, and therefore the command’s parameters entry, must point to the correct Workspace 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 Workspace, 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 Workspace script project, then copy the script's parameters.
Select the required process/procedure in the Workspace 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 Workspace script parameters in the Parameters field, then proceed as you would when creating a command from a locally-sourced script.
Paste the copied Workspace 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 NEXUS Toolbar or Menu, and run as needed.

Note that since the command's script is sourced from your Workspace, it will be only available when the user has connected to that Workspace with the correct credentials.

A menu command created from a Workspace script is functional when the user is connected to its host Workspace.
A menu command created from a Workspace script is functional when the user is connected to its host Workspace.

 

Reuse as Part of an Environment Configuration

A Script Item can be used indirectly as part of a revision of a Design 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 Workspace. Once you have connected to the Workspace, 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 Design Preferences Item revision, then that is applied straight away. If the chosen environment configuration applicable to you does not have a Design Preferences Item revision specified, then preferences will remain manually definable. In other words, you are free to manually reuse a revision of a Design Preferences Item, or use a locally saved preferences file. For more information, see Environment Configuration Management (for an Altium 365 Workspace or a NEXUS Server Workspace).

Re-Saving a Script

At any stage, you can come back to any revision of a script in the Workspace, 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 NEXUS where it can be edited as required, then saved back to the Workspace as the next revision using the Save to server command (shortcut: Ctrl+Alt+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 a script itself will edit the latest revision of that script.

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

Updating a Script

If you need to change the project or associated source stored in a Script Item, and you have the updated source files, you can upload those files to that Item – the new files will be stored in the next revision of that Item.

Downloading Files

Downloading the files (project and associated source) stored in a revision of a script can be performed from the Explorer panel in the following ways:

  • By right-clicking on that revision and choosing the Operations » Download command from the context menu. The files will be downloaded into a sub-folder under the chosen directory, named using the Item Revision ID. The files can be found in the Released folder therein.

    Access the Download command from the top-level entry for a script itself, to download the files stored in the latest revision of that script.
    Click the Explore button in the Download from Server dialog, to quickly explore to the download folder.
  • By selecting one or more source files stored in the Item Revision, on its Details aspect view tab, then right-clicking and choosing the Download command from the context menu. Nominate the target folder to receive the file(s), in the subsequent Choose destination folder dialog.

Opening a Script Source File

To open the project file that is stored in a revision of a script, or one of its associated source files, select that file – on the Details aspect view tab for the revision – then right-click and choose the Open command from the context menu. The project (all source files too) or source file(s) (as free document(s)) will be opened within Altium NEXUS.

Soft Deletion

When connected to a Workspace, flexible functionality is available for removing a script directly from within Altium NEXUS, from the Explorer panel. Right-click on the script's entry in the panel and choose the Delete Item command from the context menu. The Delete Items dialog will appear, in which to confirm the deletion. The action is actually a 'soft delete', whereby the script will be moved into the Trash area of the Workspace. The Trash is essentially a recycle bin into which any content within your Workspace can be moved (through a soft delete action). It is isolated from the rest of the Workspace.

With the soft-delete facility, you are able to delete a script that is currently being used.
Multiple scripts can be deleted in a single action. Select all required scripts using standard multi-select controls (Shift+Click, Ctrl+Click), then right-click and choose the Delete Items command from the context menu.

Soft deletion of a script. The script will be moved to the Workspace's Trash area.
Soft deletion of a script. The script will be moved to the Workspace's Trash area.

To proceed with the deletion, click the button. The script will be removed and a Deletion Summary dialog will confirm successful deletion. If there was an issue with deletion, this will be flagged to you.

All content deleted in this manner can be found on the Trash page of the Workspace's browser interface. Note that you can only view content that you have personally soft deleted. Administrators will be able to see the full content of the Trash page – so all content that has been soft deleted.

Things to consider in relation to a soft deleted script:

  • The script will not be available from your design software, or from within the Web interface.
  • Anywhere the script was being used will reflect that the script has been deleted.
  • A script can be restored, or permanently deleted from the Trash page, provided you have editing rights. Permanent deletion is only possible provided it is not being used by a parent Item.
Note that if you have soft deleted a script – moving it to the Trash – you can create a new script with that same name again. If you were to subsequently restore the original script, and the original name is taken, an integer suffix will be used, to keep its name unique within the Workspace.
If you find an issue, select the text/image and pressCtrl + Enterto send us your feedback.
Content