PDMWorks API C# Sample

Does anyone have any C# sample code to get me started using the PDMWorks API?

SolidworksApi macros
Answers 9
MM
MM 2013-12-05 Best Answer

I have a couple of vba macros. If you think you could dissect them to figure out what you need, I could send them to you.

MD
MD 2013-12-06

Brian,

Are you asking about Workgroup or Enterprise? The API documentation for Enterprise PDM 2014 has newly added examples in C#.

BC
BC 2013-12-06

This is for Workgroup, not EPDM.

I would like to stick to C# because I am more familiar with it.

I'm having trouble figuring out how to initialize the connection object before calling login on it.

MM
MM 2013-12-06

I am only familiar with VBA so I can't attest to how to initialize in C#.

In VBA the prodedure goes:

Dim pdmConn as PDMWConnection

set pdmConn = CreateObject("PDMWorks.PDMWConnection")

pdmConn.LogIn "user", "password", "server name or IP address"

Hopefully, you can find someone that can convert this to C#.

BC
BC 2013-12-06

Well I gave up and went to VB.

Could you please send those examples you mentioned?

MM
MM 2013-12-06

I am sending the .txt versions to you. Make sure you reference the Solidworks Workgroup PDM 1.0 Type Library under Tools>References to access the members.

AT
AT 2013-12-07

You can init the connection in c# something like this:

<p>PDMWConnection pdmConn;</p><p>pdmConn = Activator.CreateInstance(Type.GetTypeFromProgId("PDMWorks.PDMWConnection")) as PDMWConnection;</p><p>pdmConn.LogIn ("user", "password", "server name or IP address");</p>

____________________________________________________

Regards,

Artem Taturevych, Application Engineer at Intercad (Australia)

translationXpert – add-in to translate SolidWorks models

myIntercad – an integrated tool for SolidWorks Professionals

LinkedIn SolidWorks API Education Group

PR
PR 2018-07-23

Hi ​,

I have tryed to establish a connection as you proposed. Unfortunetly it doesn't works. The Expression
Type.GetTypeFromProgId("PDMWorks.PDMWConnection")) returns null. I have also tryed it with Version dependent progID as you can see in the following snapshot:

But both expressions returns null, so that the connection throws an error.

I have installed SolidWorks 2017 SP5 and PMD Workgroup 2017 in an Windows 10 environment.
The links to the PDM libraries you can see in the following snapshot:

What else am I doing wrong?

Thanks for ur help!

Regards

Patrick Reinke

comment imagecomment imagecomment imagecomment image
PR
PR 2018-07-24

Problem solved:

dll files wasn't proper registered in the registry.

Fix it first with regsvr32 in Windows\System32 like this

regsvr "C:\Program Files\Common Files\SolidWorks Shared\pdmworks.dll"

then Register it with regasm somewhere in Microsoft.NET Folder like this:

regams "C:\Program Files\Common Files\SolidWorks Shared\PDMWorks.Interop.pdmworks.dll /codebase"

restart your PC and after opening Visual Studio check if in Project properties the Checkbox prefer 32 Bit System is unchecked.