Skip to content
A wrapper making possible to create SolidWorks Professional PDM add-ins in any programming language, including scripting languages.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
AHK
SWPAWSourceCode
Demo.cmd
LICENSE
README.md
SWPAW.ini

README.md

SWPAW

SolidWorks PDM Add-In Wrapper

A wrapper making possible to create SolidWorks Professional PDM add-ins in any programming language, including scripting languages.

Workflow

Further information about this project

Minimum Prerequisites

  • C# 6
  • .NET 2
  • SolidWorks Enterprise PDM 2014 SP0

Getting Started

  • Add the EPDM Interop.epdm.dll/Runtime Version: v2.0.50727 to the references.
  • Sign the assembly.
  • Compile the add-in.
  • Create the user environment variable SWPAW.ini and assign the full filename to it.
  • Log out and log in again to apply changes.
  • Fit the SWPAW.ini to your needs.
  • Add the add-in to the vault.
  • Restart the system.
  • Write your own scripts to extend SolidWorks PDM.

How to debug DLLs

Hitting breakpoints in .NET Class Libraries while debugging with Visual Studio 2010

How to use the demo script for AutoHotkey

The demo script intercepts button clicks and extends the context menu of the right mouse button for selected files and folders.

  • Create the directory C:\SWPAW and copy all files and directories into it.
  • Create a button with the following properties on a PDM data card.
    • Command type: Run Add-in
    • Name of add-in: AHK:HelloWorld - The entry EdmCmd_CardButtonExecutionCondition=.<@1>^AHK:.*$ in the SWPAW.ini ensures that only buttons beginning with the name AHK: are used by the add-in.

How to debug scripts in AutoHotkey

  • Set the value DebugMode=true in the [System] section in SWPAW.ini.
  • Execute the action to be debugged in PDM.
  • Use the new created temp file and the name of the executed hook by filling in the required information in the </Only for debugging> area in BiIMainScript.ahk.
  • Run the debugger for AutoHotkey.

Where to find an IDE for AutoHotkey

How to start with SQL and AutoHotkey

How to start with PDM and AutoHotkey

  • Logs in to the specified vault.
_vault := ComObjCreate("ConisioLib.EdmVault")			
_vault.LoginAuto[<vault name>, 0]
  • Gets the PDM file object via file id.
_file := _vault.GetObject(EdmObject_File, <file id>)
  • Gets a variable value by ref. This script is required.
_objVarValue := ComVar()
_var := _file.GetEnumeratorVariable("")
_var.GetVar(<variable name>, <configuration name>, _objVarValue.ref)
_varValue := _objVarValue[]
ComVarDel(_objVarValue)
  • Gets a list of names of the configurations for the specified version of this file.
_configList := _file.GetConfigurations()
_pos := _configList.GetHeadPosition()
while(!_pos.IsNull){
	_configurationName := _configList.GetNext(_pos)
}
_search := _vault.CreateSearch()
_search.SetToken(1, 1)
;~ Set all required tokens.
_searchResult := _search.GetFirstResult()
while(_searchResult){
	_searchResult := _search.GetNextResult()
}

How to run scripts in AutoHotkey

To work correctly executed scripts have to return an ErrorLevel for the evaluation in AutoHotkey. All integers except 0 are errors.

  • Starts a VBScript and waits for its completion. To return an ErrorLevel it ends with WScript.Quit(0).
cscript := "C:\Windows\System32\cscript.exe"
vbscript := "C:\SWPAW\VBS\Demo.vbs"	
RunWait, %cscript% %vbscript%,, Hide UseErrorLevel, scriptPid
  • Starts a batch script and waits for its completion. To return an ErrorLevel it ends with Exit 0.
batchscript := "C:\SWPAW\BAT\tmp.bat"
RunWait, %batchscript%,, Show UseErrorLevel, scriptPid

The calling of scripts and programs always follows the above pattern.

  • After completion of the script, you can evaluate the ErrorLevel and handle errors. Error code and error message will be passed to SWPAW.
if(ErrorLevel != 0)
{
	errorCode := ErrorLevel
	if(errorCode = 1)
	{
		errorMsg := "Error 1 in script."
	}
	else if(errorCode = 2)
	{
		errorMsg := "Error 2 in script."
	}		
	else
	{
		errorMsg := "Unknown error " . errorCode . " in script."		
	}		
	return		
}
You can’t perform that action at this time.