Table of Contents

Scripting in PDMShell

Save repeatable work in a .pdmshell script and run it from the editor, the PDMShell console, or an external application.

Create and save a script

Use New/Open/Save in the main editor. Plain-text scripts are supported, but files saved by the editor can also contain visual layout data. Edit those files in PDMShell rather than treating them as plain text. See Save and open scripts.

Storage How to edit it
Standalone .pdmshell file Open the file in the main editor and save.
Vault script Connect to the vault, choose Open > Vault script, edit its code/settings, and save.
PDM task Edit the stored script directly in task properties, or import a saved script. Enable Link to vault script to use its latest saved code.

Write one command per line. A line beginning with # is a comment; put comments on separate lines rather than after commands.

Interactive scripts can use file and folder pickers and reuse the selection through ${local.Name} or ${global.Name}. For unattended automation, supply paths explicitly.

Run a saved file

Connect to the vault first, or configure automatic login for the account running the script. The script file must be readable on that computer.

From the PDMShell console:

runscript -source "C:\Scripts\Inspect.pdmshell" -filePath "C:\Vault\Parts\1001.sldprt"

From the Windows command line:

pdmcli.exe "C:\Scripts\Inspect.pdmshell" -filePath "C:\Vault\Parts\1001.sldprt"

Use the full path to your installed pdmcli.exe if it is not on PATH. Find it from the PDMShell shortcut rather than assuming an installation folder. Use -edit to open the script without running it:

pdmcli.exe -edit "C:\Scripts\Inspect.pdmshell"

To run without the full editor, add -headless and pass known targets with -items:

pdmcli.exe -headless "C:\Scripts\Inspect.pdmshell" -items "C:\Vault\Parts\1001.sldprt;C:\Vault\Parts\1002.sldprt"

-items accepts complete file/folder paths and ID pairs in the same semicolon-separated list. A folder is one target; it does not expand into its children. Use commands appropriate to each target type. See items format and the headless example. Headless uses a smaller shell window and can still show prompts; end an automation script with quit -silent to close it.

Work with selected files

-source identifies the script. Choose one target selector: -filePath, -id, -search, or -items. Inside the script, use -filePath "$localPath" on commands that should act on that file.

For example, Inspect.pdmshell can contain:

fileinfo -filePath "$localPath"

Use -search to supply several targets:

runscript -source "C:\Scripts\Inspect.pdmshell" -search "Name=%.sldprt" -recursive

With optimized execution, consecutive item-specific lines run for each target, while lines without item-specific values run once. To run the entire script for one target before moving to the next, enable Do not use optimized script execution in Settings. See RUNSCRIPT execution and placeholders.

Close after automation and read the result

Add quit -silent at the end when an external application should wait for PDMShell to finish:

fileinfo -filePath "$localPath"
quit -silent

When the standalone process closes, its exit code is 0 for success or 1 if a command/script failed or was canceled. Later successful commands do not clear a failure. If execution stops before reaching quit, the application can remain open.

Use a separate process when you need its result. -single forwards commands to an existing window without waiting for its script result. See the PowerShell exit-code example.

Reports and PDM integration

  • RUNSCRIPT documents every parameter, placeholder and search-only -csv report.
  • Command-line startup and instances explains startup switches and instance reuse.
  • Dispatch and workflow transitions can start an external script.
  • The PDMShell add-in runs vault scripts from PDM menus and events. Edit vault scripts in standalone PDMShell.
  • PDM tasks run through task hosts and the Task List. Configure script linking, launch inputs, error handling and permissions in task properties.