Parent page: Workspace Content Types
Altium Designer, 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 Designer. In Altium Designer, 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 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 (Altium 365 Workspace, Enterprise Server Workspace).
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.](/documentation/sites/default/files/wiki_attachments/305583/DwaCWS_Scripts_FolderType_AD21_9.webp)
Specifying the folder type – its intended use – gives a visual indication of the content of that folder when browsing the Workspace.
Item Naming Scheme
Another important aspect of the parent folder is the Item Naming Scheme employed for it. This defines the format of the unique ID for each Item created in that particular folder. Several default example schemes are available, utilizing the short-form code for either the folder type (ASC
– Altium Script Catalog) or the content type (ASF
– Altium Script File):
$CONTENT_TYPE_CODE-001-{0000}
– for example, ASF-001-0001
.
$CONTENT_TYPE_CODE-001-{A00}
– for example, ASF-001-A01
.
$FOLDER_TYPE_CODE-001-{0000}
– for example, ASC-001-0001
.
$FOLDER_TYPE_CODE-001-{A000}
– for example, ASC-001-A001
.
Using a default naming scheme, the software will automatically assign the next available unique ID, based on that scheme, having scanned the entire Workspace and identifiers of existing content. This can be a great time-saver when manually creating scripts.
A custom scheme can also be defined for a folder, simply by typing it within the field, ensuring that the variable portion is enclosed in curly braces (e.g. SCRIPT-001-{0000}
).
![The Item Naming Scheme of the parent folder is applied to the Unique ID for each Item created within that folder. The Item Naming Scheme of the parent folder is applied to the Unique ID for each Item created within that folder.](/documentation/sites/default/files/wiki_attachments/305583/Scripts_ItemNamingScheme_19_0.webp)
The Item Naming Scheme of the parent folder is applied to the Unique ID for each Item created within that folder.
The Item Naming Scheme employed for the parent folder can be changed at any time. The modified scheme will then be applied to any subsequent newly-created content within that folder.
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.](/documentation/sites/default/files/wiki_attachments/305583/DwaCWS_Scripts_ItemType_AD21_9.webp)
Creating a script within a Scripts
folder – the correct Content Type is available on the context menu.
Item Lifecycle Definition and Revision Naming
Related pages: Defining Revision Naming Schemes for a Workspace, Defining Lifecycle Definitions for a Workspace
When defining a Script Item, to which the source script project is uploaded, be sure to specify the type of lifecycle management to be used for the Item, and the naming scheme employed for its revisions, respectively.
Control over which content types can use a particular lifecycle definition or revision naming scheme, can be defined and enabled at a global level from within the Content Types dialog, when defining each schema. The default schemes assigned for use by a script are: Generic Lifecycle
and 1-Level Revision Scheme
, respectively.
Once a file has been uploaded into the initial revision of a Script Item, these schemes cannot be changed for that particular Item.
Specify the required schemes in the Create New Item dialog, using the Lifecycle Definition and Revision Naming Scheme fields respectively.
If the option to control use of lifecycle definitions and revision naming schemes per content type is enabled for any definitions/schemes, and the Script content type is not set to use a particular definition/scheme, then that definition/scheme will not be available in the applicable drop-down list.
![Selecting the Lifecycle Definition and Revision Naming schemes for a manually created script. Selecting the Lifecycle Definition and Revision Naming schemes for a manually created script.](/documentation/sites/default/files/wiki_attachments/305583/Scripts_LifecycleandRevisionNaming_19_1.webp)
Selecting the Lifecycle Definition and Revision Naming schemes for a manually created script.
Observing standard revision naming schemes and lifecycle definitions, across the various types of design content in a Workspace ensures smooth, consistent management of this content.
It is a good idea to add a Name and Description as part of the script's definition. This information is used when searching the Workspace and enables quick identification of what a script offers.
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.](/documentation/sites/default/files/wiki_attachments/305583/DwaCWS_Scripts_UploadEx_AD21_9.webp)
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.](/documentation/sites/default/files/wiki_attachments/305583/DwaCWS_Scripts_Uploaded_AD21_9.webp)
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.](/documentation/sites/default/files/wiki_attachments/305583/DwaCWS_Scripts_DragnDropEx_AD21_9.webp)
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 Designer (under your valid Altium Designer 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 Designer:
- Choose the File » Run Script command from the main menus.
- In the Select Item To Run dialog, click the
button and choose the From server entry.
- 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.
- 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.](/documentation/sites/default/files/wiki_attachments/305583/DwaCWS_Scripts_RunScriptEx_AD21_9.webp)
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 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 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 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.](/documentation/sites/default/files/wiki_attachments/305583/DwaCWS_Scripts_ChoosingScriptProjecttoInstallEx_AD21_9.webp)
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 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.](/documentation/sites/default/files/wiki_attachments/305583/MCS_Scripts_ManagedScriptProjectInstalled_20_1.webp)
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 Designer, 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.](/documentation/sites/default/files/wiki_attachments/305583/Scripts_AccessEditCommandDlg_20_1.webp)
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.](/documentation/sites/default/files/wiki_attachments/305583/Scripts_CopyScriptParameters_19_0.webp)
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.](/documentation/sites/default/files/wiki_attachments/305583/Scripts_CustomCommandCreated_20_1.webp)
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 Designer 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.](/documentation/sites/default/files/wiki_attachments/305583/Scripts_RunningaScriptCommandEx_AD21_9.webp)
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. A menu command created from a Workspace script is functional when the user is connected to its host Workspace.](/documentation/sites/default/files/wiki_attachments/305583/Scripts_RunningaScriptCommandEx_AN4_9.webp)
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 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 Designer 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 (Altium 365 Workspace, Enterprise Server 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 Designer 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.](/documentation/sites/default/files/wiki_attachments/305583/DwaCWS_Scripts_EditExistingRevisionEx_AD21_9.webp)
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 Designer.
Soft Deletion
When connected to a Workspace, flexible functionality is available for removing a script directly from within Altium Designer, 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.](/documentation/sites/default/files/wiki_attachments/305583/DwaCWS_Scripts_SoftDeleteEx_AD21_9.webp)
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.