The SOLIDWORKS Document Manager is a powerful tool used for reporting content and manipulating SOLIDWORKS parts, assemblies and drawings. I’ve used it to export custom properties from thousands of SOLIDWORKS files in seconds! It can be used to read bill of materials and other tables from drawings as well as update references when files are renamed.
But, just like any other project, it can take time to get started and get familiar with the calls needed. To make that all easier, I’ve put together a Visual Studio 2010 project in VB.NET I’m calling the Document Manager Toolkit.
I’ll be presenting the toolkit along with a general discussion of the SOLIDWORKS Document Manager at SOLIDWORKS World 2016 in Dallas, TX next week. Hope to see you there!
“What’s in the toolkit?” you ask? Download the project here for a sample implementation and read up on the general functionality below.
Document Manager Toolkit Download
Document Manager Presentation PDF (SOLIDWORKS World 2016)
MyDocMan Class
The MyDocMan class is the basis for the toolkit. It takes care of license validation and a plethora of common operations shared below. The functions and procedures are documented in the project to make it easier to use in your own tools.
Instantiating the class will connect to the SOLIDWORKS Document Manager and is built to read your Document Manager license from a text file named “DocMgrLicense.txt” from C:\. Edit the GetDocManApp procedure to insert and compile your license, redirect the license file location, or point to license information saved in My.Settings.
Common Operations
GetDocument
Summary:From a full file path, return an opened SwDMDocument.
Parameters:
FilePath: full path to the desired SOLIDWORKS file
forReadOnly: True to open the file read-only, False to open with write access.
Return Values:
Returns an SwDMDocument interface if successful.
GetAllProperties
Summary:Function to read all file and configuration specific custom properties from a document.
Parameters:
dmDoc: Document Manager document
Return Values:
A tab-delimited string containing all configuration names, properties and values. An empty string in the configuration column indicates a file property.
Remarks:
Each line in the string will terminate in a carriage return character.
GetDelimitedTableText
Summary:Get all text from a named table with the desired delimiter.
Parameters:
tableName: Name of the table in the SOLIDWORKS file
dmDoc: the SwDMDocument10 interface containing the table
delimiter: the desired column delimiter
Return Values:
A string representing the text of the entire table, including headers. Return characters are applied between rows.
GetBOMTableNames
Summary:Gets all table names from a document.
Parameters:
dmDoc: The desired document containing tables.
Return Values:
An array of strings in an Object.
Remarks:
Use this function before calling GetDelimitedTableText to retrieve a valid BOM table name.
GetMissingReferences
Summary:Recursive routine to report all missing file references.
Parameters:
dmDoc: Parent document of reported children, typically an assembly or drawing.
Remarks:
Reports back a string of missing reference files separated by a return character.
File Operations
BrowseForFileGetFilesFromPath
BrowseForFile
Summary:Browse for a SOLIDWORKS file using the Windows OpenFileDialog
Return Values:
Returns the full path to the selected file.
GetFilesFromPath
Summary:Get all file paths from a user-selected directory.
Parameters:
extensionFilter: a file extension to filter. "*.sld*" would retrieve all SOLIDWORKS files.
includeSubFolders: Set to True to get files from all sub folders
Return Values:
Returns an array of full file paths.
Remarks:
Temp files, ~$Part1.sldprt, should be filtered from your results before processing.