This topic provides information to help you get started with using the SolidWorks Document Manager API.
License Key
The SolidWorks Document Manager API requires a license key that is only available via the SolidWorks customer portal to SolidWorks customers who are currently under subscription.
To request a SolidWorks Document Manager API license key:
- Log into the SolidWorks customer portal.
- Click API Support in My Support.
- Click Document Manager key request in step 4.
- Follow the online instructions to request your license key.
A SolidWorks Document Manager API license key is emailed to you upon approval of your request.
IMPORTANT: Do not share this license key with anyone outside your company or distribute it with any software that you ship.
You must specify the license key when instantiating a SolidWorks Document Manager API connection. See Application Basics for details.
Back to top
Software Requirements
The SolidWorks Document Manager API requires MSXML 4.0 (Microsoft XML Core Services) or later; MSXML 6.0 is the first version of MSXML that supports 64-bit processors.
NOTE: SolidWorks installs MSXML 4.0 by default, and MSXML is only needed if you want to use ISwDMComponent or ISwDMComponent2. If you need a later version of MSXML, download it from www.microsoft.com.
Back to top
Installation
Read the Software Requirements section before proceeding. MSXML must be installed in order to successfully register the SolidWorks Document Manager DLLs.
The SolidWorks Document Manager API is a COM object contained in SwDocumentMgr.dll. The SolidWorks Document Manager DimXpert API is contained in dimxpert.dll. The zlib.dll DLL was automatically installed in the following folder if you installed the SolidWorks software:
<disk>:\Program Files\Common Files\SolidWorks Shared
SwDocumentMgr.dll and dimxpert.dll were also automatically registered if you installed the SolidWorks software.
If you did not install the SolidWorks software on the system where you want to use these APIs, you can manually register them.
SwDocumentMgr.dll and zlib.dll must either reside in the same folder or be accessible via the Windows search path.
To manually register SwDocumentMgr.dll:
-
Click Start, Run.
-
In the dialog box, type:
regsvr32 "<disk>:\Program Files\Common Files\SolidWorks Shared\SwDocumentMgr.dll"
-
Click OK.
-
Click OK again.
NOTE: Install programs, such as InstallShield, can automatically register the DLL for you.
To manually unregister SwDocumentMgr.dll:
-
Click Start, Run.
-
In the dialog box, type:
regsvr32 /u "<disk>:\Program Files\Common Files\SolidWorks Shared\SwDocumentMgr.dll"
-
Click OK.
-
Click OK again.
You can redistribute swDocumentMgr.dll and zlib.dll.
To manually register dimxpert.dll:
-
Click Start, Run.
-
In the dialog box, type (vX.X is the name of a version directory that contains RegAsm.exe):
C:\WINDOWS\Microsoft.NET\Framework\vX.X\regasm /codebase "<disk>:\Program Files\Common Files\SolidWorks Shared\dimxpert.dll
-
Click OK.
Back to top
Application Basics
Writing a SolidWorks Document Manager application typically involves:
-
Instantiating a SolidWorks Document Manager connection (ISwDMClassFactory::GetApplication).
NOTE: You must have a license key from SolidWorks Corporation to instantiate the application object.
-
Opening a file (ISwDMApplication::GetDocument).
-
Querying the file for data such as custom properties, configurations, references, and where the file is used (ISwDMConfiguration::GetBodiesCount, ISwDMConfiguration::GetCustomPropertyNames, ISwDMDocument::GetAllExternalReferences, ISwDMDocument::GetHyperLinkAt).
-
Extracting data such as Parasolid bodies, embedded eDrawings data, and XML data from assembles (ISwDMConfiguration::GetBody, ISwDMDocument::GetEDrawingsData, ISwDMDocument::GetXMLStream).
-
Extracting features and annotations from DimXpert parts (ISwDMConfiguration12:DimXpertPart).
-
Making changes (ISwDMDocument::AddCustomProperty, ISwDMDocument::DeleteCustomProperty, ISwDMDocument::ModifyHyperLinkAt, ISwDMDocument::ReplaceReference, ISwDMDocument::SetCustomProperty).
-
If any changes are made, saving the document (ISwDMDocument::Save or ISwDMDocument::SaveAs).
-
Closing the document (ISwDMDocument::CloseDoc).
NOTE: You must close a document before you can copy or move it using ISwDMApplication::CopyDocument or ISwDMApplication::MoveDocument.
Be sure to examine all returned error codes.
NOTE: Documents created using SolidWorks 99 (Version 1137) or earlier are not supported by this API. See ISwDMDocument::GetVersion for a detailed list of SolidWorks versions supported by this API.
Back to top