Getting Started with SolidWorks PDM API
An introduction to the SolidWorks PDM Professional API — connecting to vaults, reading file metadata, and building add-ins. Covers the key differences from the SolidWorks API.
PDM API vs SolidWorks API
The SolidWorks PDM API is a completely separate COM library from the SolidWorks API. They share no interfaces. The key differences:
- SolidWorks API: Controls the CAD application — models, features, drawings, geometry
- PDM API: Controls the vault — files, folders, workflows, variables, users, revisions
- Different DLLs: PDM uses EPDM.Interop.epdm, not SolidWorks.Interop.sldworks
- Different threading: PDM API can run in background services; SolidWorks API requires STA
Setting Up Your Project
- Create a .NET Framework class library project (PDM add-ins must target .NET Framework, not .NET 5+)
- Add a reference to EPDM.Interop.epdm from the PDM installation folder
- Add a reference to EPDM.Interop.EPDMResultCode for error handling
The Primary Interop Assemblies (PIAs) are typically found in:
C:\Program Files\SOLIDWORKS PDM\EPDM.Interop.epdm.dllConnecting to a Vault
var vault = new EdmVault5();
vault.LoginAuto("MyVaultName", 0); // Uses Windows authLoginAuto uses the currently logged-in Windows user's credentials. For explicit login:
vault.Login("username", "password", "MyVaultName");Reading File Information
IEdmFile5 file;
IEdmFolder5 folder;
vault.GetFileFromPath("C:\\Vault\\Parts\\Bracket.sldprt", out file, out folder);
// Read file variables (custom properties in PDM)
var varMgr = file.GetEnumeratorVariable("");
string partNumber = "";
varMgr.GetVar("PartNumber", "@", out partNumber);
// Get current workflow state
var state = file.CurrentState;
Console.WriteLine($"State: {state.Name}");Types of PDM Development
Standalone Applications
Regular .exe programs that connect to the vault externally. Good for batch tools, reports, and integrations. Can run without PDM client UI.
PDM Add-ins
DLLs that load inside the PDM client. Respond to vault events (file check-in, state change, etc.) and add custom menu items. Must implement IEdmAddIn5.
Task Add-ins
Special add-ins that run as scheduled or triggered tasks on the PDM task host. Used for conversion (PDF generation), data synchronization, and automated workflows.
Dispatch Scripts
No-code automation built into PDM. Can execute programs, send emails, and manipulate files based on workflow transitions. Good for simple automation without writing code.
Common Pitfalls
- Vault login scope: Each process needs its own vault connection. Don't share EdmVault5 across threads
- File locking: Always check a file out before modifying it, and check it back in when done
- Variable scoping: Variables can be file-level or configuration-level, similar to SolidWorks custom properties
- Testing: You can't easily unit test PDM code — use a test vault and integration tests
- Deployment: PDM add-ins must be installed on every client machine via the PDM admin tool