The Undocumented Documented "Document Manager DLL"

Huh, what was that? There is a little known feature of SolidWorks called the Document Manager Dll, and it is actually very well documented! A few years ago I ran across a posting about how programmers were able to extract custom property information from a SolidWorks part file without having SolidWorks open. As I looked into it further, I found that this was done by accessing a special dll named SwDocumentMgr.dll.

If you have SolidWorks installed, the actual dll can be found in the  C:Program FilesCommon FilesSolidWorks Shared directory.

So, what can you do with this little wonder object?
– You can Get and Set the custom/configuration specific properties.
– You can Get and Set references in an assembly file. (Very powerful, and scary!)
– You can extract the parasolid (The solid model).
– You can extract the preview Bitmap. Yes, that is pretty sweet!
– You can extract eDrawing data.
– You can extract data out into an xml format. (Basically, export xml of all sub parts and assemblies, etc.)

The documentation on its capabilities, API, and example code can be found in your SolidWorks directory. On my computer, it can be found here:
C:Program FilesSolidWorksapiswdocmgrapi.chm

You don’t have to be a rocket scientist to use the dll. It is COM based, and simple to consume in your application.
If you are using vb6 or .Net, make sure you reference the SwDocumentMgr 200x type library.

Probably the biggest caveat to using the dll is that you need a key. Without the key the application will fail. I have read somewhere that any file after 2007 doesn’t need a key. However, I haven’t tried this. You can easily get a key though. Just email apisupport@solidworks.com. They will be glad to set you up with one. You may need to be an existing customer though…. not sure on that one.

With just a few lines of code, and more importantly, without starting (or even having) SolidWorks you can accomplish some very cool things!

‘ Get the Document Mgr application Object.
classfac = CreateObject(“SwDocumentMgr.SwDMClassFactory”)
DMapp = classfac.GetApplication(“your_license_key”)

‘ Get the document mypart.sldprt. Then grab the configurationmanager object for the default configuration
swDoc = DMapp.GetDocument(“C:MyPart.SLDPRT”, swDmDocumentPart, True, e)
c = swDoc.ConfigurationManager.GetConfigurationByName(“Default”)

‘ Grab the custom property “MyDimension” for the Default configuration!
Debug.WriteLine(c.GetCustomProperty(“MyDimension”, e))

Contact Inflow Technology for more information.

  • Share this
Find Your Design Solution in the CATI Store.
Browse Products