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. Each user of SOLIDWORKS Document Manager API must have a license key.
Existing users must request new SOLIDWORKS Document Manager API license keys beginning with SOLIDWORKS Document Manager API 2015 FCS and renew their SOLIDWORKS Document Manager API license keys when installing any new major release of SOLIDWORKS or the SOLIDWORKS Document Manager API.
SOLIDWORKS Document Manager API checks the version of the file being accessed. If the file was created using the same or an earlier version of SOLIDWORKS than the version of SOLIDWORKS Document Manager API license key, then SOLIDWORKS Document Manager API can access the file. However, if the file was created using a later version of SOLIDWORKS than the version of the SOLIDWORKS Document Manager API license key, then SOLIDWORKS Document Manager API cannot access the file and a message is displayed informing the user that the current SOLIDWORKS Document Manager API license key is expired. For example:
Version in which SOLIDWORKS file created |
Version of SOLIDWORKS Document Manager API license key |
File Access Result |
2014 or earlier |
2014 or earlier |
Success |
2015 or later |
2014 or earlier |
Failure |
2015 or earlier |
2015 or later |
Success |
When requesting or renewing a SOLIDWORKS Document Manager API license key, you are presented with a dialog containing a list of check boxes showing the categories of functionality that a SOLIDWORKS Document Manager API license key controls. You can select more than one category.
- Basic: All interfaces, methods, and properties except for those listed below
- Previews: Preview and stream methods and properties on all ISwDMConfiguration, ISwDMDocument, and ISwDMSheet interfaces
- DimXpert: DimXpert methods and properties on all ISwDMConfiguration and all DimXpert-related interfaces
- Geometry Streams: Preview, stream, and imported body methods and properties on all ISwDMConfiguration interfaces
- XML Streams: XML stream methods on all ISwDMDocument interfaces
- Tesselation: Display List DLL (previously called the Display List Sample); although not a component of the SOLIDWORKS Document Manager API, its license key controls access to the Display List DLL
To request a SOLIDWORKS Document Manager API license key: https://www.solidworks.com/support/subscription/key-request/
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:
- Visual C++ Redistributable for Visual Studio 2015, which installs the runtime components of Visual C++ libraries. These runtime components are required to successfully register the SOLIDWORKS Document Manager 2018 DLL, which was developed using Visual Studio 2015.
- Microsoft Core XML Services (MSXML) 4.0 or later; MSXML 6.0 is the first version of MSXML that supports 64-bit processors. MSXML is only needed if you want to use ISwDMComponent or ISwDMComponent2. Download MSXML from www.microsoft.com.
NOTE: A full SOLIDWORKS 2018 installation includes MSXML and the Visual C++ Redistributable for Visual Studio 2015. Clients installing SOLIDWORKS Document Manager on systems without a full SOLIDWORKS installation must also install MSXML and the Visual C++ Redistributable or ensure that they have been previously installed.
Back to top
Installation
Read the Software Requirements section before proceeding. MSXML and the Visual C++ Redistributable for Visual Studio 2015 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:
-
On the task bar, click the search icon.
-
Type "C" in the Type here to search field.
-
Right-click on Command Prompt, and select Run as administrator.
-
Click Yes in the dialog box.
-
In the Administrator Command Prompt, type:
regsvr32 "<disk>:\Program Files\Common Files\SOLIDWORKS Shared\SwDocumentMgr.dll"
-
Click OK.
NOTE: Install programs, such as InstallShield, can automatically register the DLL for you.
To manually unregister SwDocumentMgr.dll:
-
Follow steps 1-4 in the manual registration instructions above.
-
In the Administrator Command Prompt, type:
regsvr32 /u "<disk>:\Program Files\Common Files\SOLIDWORKS Shared\SwDocumentMgr.dll"
-
Click OK.
You can redistribute swDocumentMgr.dll and zlib.dll.
To manually register dimxpert.dll:
-
On the task bar, click the search icon.
-
Type "C" in the Type here to search field.
-
Right-click on Command Prompt, and select Run as administrator.
-
Click Yes in the dialog box.
-
In the Administrator Command Prompt, 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 and XML data from assemblies (ISwDMConfiguration::GetBody and ISwDMDocument::GetXMLStream).
-
Extracting features and annotations from DimXpert parts (ISwDMConfiguration12:DimXpertPart).
-
Making changes (ISwDMDocument::AddCustomProperty, ISwDMDocument::DeleteCustomProperty, ISwDMDocument::ModifyHyperLinkAt, ISwDMDocument::ReplaceReference, ISwDMDocument::SetCustomProperty, etc.).
-
If any changes are made, saving the document (ISwDMDocument::Save or ISwDMDocument::SaveAs).
NOTE: If recreating an application using an example and the example uses a SOLIDWORKS sample file, do not save changes.
-
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
Third-party Data in SOLIDWORKS Files
Starting with SOLIDWORKS 2015, third-party data stored in SOLIDWORKS files cannot be externally read or written by standard structured storage or compound file techniques.
To read or write third-party data, use the methods and events in the SOLIDWORKS API or SOLIDWORKS Document Manager API.
SOLIDWORKS API:
SOLIDWORKS Document Manager API:
Back to top