Search

Ultimate Guide For Getting Started With Document Manager

Document Manager is powerful stand-alone library supplied by SOLIDWORKS which allows to read and write metadata directly from SOLIDWORKS files stream.

Benefits

  • Free for customers or SOLIDWORKS partners (research, solution or gold) on subscription
  • Lightweight - library is about 13 MB in size
  • Stand-alone - doesn't require SOLIDWORKS to be installed in order to access the files
  • Quick - data is accessed directly from the stream without the need to load the full file into the memory

Notes

  • Document Manager has a limited functionality compared to full SOLIDWORKS API
  • Document Manager key must not be shared outside of the organization
  • Software developed using Document Manager key can only be redistributed in the binary format
    • That means that the customers of your software do not need to get the license key from SOLIDWORKS
    • That also means that this key cannot be used in VBA macros outside of the organization, but can be used in VSTA macros (if source code is not redistributed)
  • Document Manager is backward compatible until the SOLIDWORKS 2015 but it is not forward compatible. For example it is possible to read/write legacy data with newer version of Document Manager key for SOLIDWORKS 2015 onwards.
    • Document Manager key generated before SOLIDWORKS 2015 is both backward and forward compatible with older versions of SOLIDWORKS
  • Document Manager license key should be updated with every new release of SOLIDWORKS to support newer versions
  • Document Manager COM dll must be registered with regsvr32 utility on all target machines utilizing the Document Manager API.
    • Document Manager is automatically registered with the following applications
      • SOLIDWORKS
      • eDrawings
      • SOLIDWORKS Files Explorer
      • SOLIDWORKS PDM
      • SOLIDWORKS Document Manager SDK
    • If none of the above application is installed on a target machine it is required to register the swdocumentmanager.dll (usually installed to C:\Program Files\Common Files\SOLIDWORKS Shared\swdocumentmgr.dll with Document Manager SDK). Important for .NET developers: the swDocumentManager.dll is not the same as SolidWorks.Interop.SwDocumentMgr.dll which is added as the reference to the project. The later one doesn't contain any implementation - this is just an interop to access COM objects implemented in swDocumentManager.dll

Supported Functionality

  • Basic
    • Reading/Writing Custom Properties (including configuration specific and summary information)
    • Reading file relationships (assembly Bill of Materials and drawings)
    • Replacing file relationships (components and drawing view references)
    • Reading components transformations in the assembly
    • Reading tables data in models and drawings
    • Reading 3rd party storage data
    • Getting the information about the configurations, drawing views and their properties
  • Previews
    • Getting 2D image previews from files and configurations
  • DimXpert
    • Accessing DimXpert dimensions
    • Accessing DimXpert features
  • Geometry Streams
    • Getting Parasolid geometry
  • XML Streams
    • Reading embedded assembly XML data
    • Reading 3D Content Central data
  • Tesselation
    • Getting the tessellation (triangulation) data (if stored in the model)

Application

List of possible applications which could be developed with Document Manager API includes but not limited to the following types of software:
  • Product Data Management (PDM) or Product Lifecycle Management (PLM) application
    • Bill Of Materials
    • Preview
    • Properties
  • 3D Viewers for SOLIDWORKS files
  • CAD systems with the requirement of importing the SOLIDWORKS files
  • Inspection software with requirements to access DimXpert data

Activating Document Manager

Document manager requires the developer license which can be requested via SOLIDWORKS customer portal.

Follow the steps below
  1. Login to customer portal
  2. Click API Support link under My Support section
  3. Select Document Manager Key Request link
  4. Select the option either to resend existing key or generate new one
  5. Fill the request form and select the functionality required for your software (refer Supported Functionality section to select the right functions)

  6. It usually takes several business days for key to be generated. Once generated it will be sent via e-mail.
The key is generated in the following format:
[CompanyName]:swdocmgr_general-00000-{31 times},swdocmgr_previews-00000-{31 times},swdocmgr_dimxpert-00000-{31 times},swdocmgr_geometry-00000-{31 times},swdocmgr_xml-00000-{31 times},swdocmgr_tessellation-00000-{31 times}

Class is not licensed for use (Exception from HRESULT: 0x80040112) exception will be thrown if API is called which doesn't belong to a group for which licenses were generated.

References

Code Examples

VBA Add the reference to swdocumentmgr.dll. The dll can be usually found at C:\Program Files\Common Files\SOLIDWORKS Shared
Const SW_DM_KEY As String = "[CompanyName]:swdocmgr_general-00000-{31 times},swdocmgr_previews-00000-{31 times},swdocmgr_dimxpert-00000-{31 times},swdocmgr_geometry-00000-{31 times},swdocmgr_xml-00000-{31 times},swdocmgr_tessellation-00000-{31 times}"

Dim swDmClassFactory As SwDocumentMgr.swDmClassFactory
Dim swDmApp As SwDocumentMgr.SwDMApplication

Sub main()

    Set swDmClassFactory = CreateObject("SwDocumentMgr.SwDMClassFactory")
    
    If Not swDmClassFactory Is Nothing Then
        Set swDmApp = swDmClassFactory.GetApplication(SW_DM_KEY)
        Debug.Print swDmApp.GetLatestSupportedFileVersion()
    Else
        MsgBox "Document Manager SDK is not installed"
    End If
    
End Sub
C# Add the reference to SolidWorks.Interop.swdocumentmgr.dll. The dll can be usually found at C:\Program Files\Common Files\SOLIDWORKS Shared. Uncheck the Embed Interop Types option in the reference properties.
using SolidWorks.Interop.swdocumentmgr;
using System;

namespace CodeStack
{
    class Program
    {
        const string SW_DM_KEY = "[CompanyName]:swdocmgr_general-00000-{31 times},swdocmgr_previews-00000-{31 times},swdocmgr_dimxpert-00000-{31 times},swdocmgr_geometry-00000-{31 times},swdocmgr_xml-00000-{31 times},swdocmgr_tessellation-00000-{31 times}";

        static void Main(string[] args)
        {
            SwDMClassFactory classFactory = Activator.CreateInstance(
                Type.GetTypeFromProgID("SwDocumentMgr.SwDMClassFactory")) as SwDMClassFactory;

            if (classFactory != null)
            {
                SwDMApplication dmApp = classFactory.GetApplication(SW_DM_KEY);
                Console.WriteLine(dmApp.GetLatestSupportedFileVersion());
            }
            else
            {
                throw new NullReferenceException("Document Manager SDK is not installed");
            }
        }
    }
}
VB.NET Add the reference to SolidWorks.Interop.swdocumentmgr.dll. The dll can be usually found at C:\Program Files\Common Files\SOLIDWORKS Shared. Uncheck the Embed Interop Types option in the reference properties.
Imports SolidWorks.Interop.swdocumentmgr
Imports System

Module CodeStack

    Const SW_DM_KEY As String = "[CompanyName]:swdocmgr_general-00000-{31 times},swdocmgr_previews-00000-{31 times},swdocmgr_dimxpert-00000-{31 times},swdocmgr_geometry-00000-{31 times},swdocmgr_xml-00000-{31 times},swdocmgr_tessellation-00000-{31 times}"

    Sub Main(ByVal args As String())

        Dim classFactory As SwDMClassFactory =
            TryCast(Activator.CreateInstance(Type.GetTypeFromProgID("SwDocumentMgr.SwDMClassFactory")), SwDMClassFactory)

        If classFactory IsNot Nothing Then
            Dim dmApp As SwDMApplication = classFactory.GetApplication(SW_DM_KEY)
            Console.WriteLine(dmApp.GetLatestSupportedFileVersion())
        Else
            Throw New NullReferenceException("Document Manager SDK is not installed")
        End If

    End Sub

End Module
C++ Add the path to swdocumentmgr.dll (usually C:\Program Files\Common Files\SOLIDWORKS Shared) into the Project Properties->C/C++->General->Additional Include Directories
#include "stdafx.h"
#import "SwDocumentMgr.dll" raw_interfaces_only
#include <iostream>

#define SW_DM_KEY L"[CompanyName]:swdocmgr_general-00000-{31 times},swdocmgr_previews-00000-{31 times},swdocmgr_dimxpert-00000-{31 times},swdocmgr_geometry-00000-{31 times},swdocmgr_xml-00000-{31 times},swdocmgr_tessellation-00000-{31 times}"

int main()
{
    CoInitialize(NULL);

    CComPtr pClassFactory;

    if (SUCCEEDED(pClassFactory.CoCreateInstance(
        __uuidof(SwDocumentMgr::SwDMClassFactory), NULL, CLSCTX_INPROC_SERVER)))
    {
        CComPtr pDmApp;

        if (SUCCEEDED(pClassFactory->GetApplication(SW_DM_KEY, &pDmApp)))
        {
            long latestVers;

            HRESULT r = pDmApp->GetLatestSupportedFileVersion(&latestVers);

            if (SUCCEEDED(r))
            {
                std::cout << latestVers;
            }
            else
            {
                std::cout << "Failed to get version";
            }
        }

        pDmApp = NULL;
        pClassFactory = NULL;
        ::CoUninitialize();
    }
    else
    {
        std::cout << "Document Manager SDK is not installed";
    }
    
    std::cin.get();

    return 0;
}

No comments:

Post a Comment