Hide Table of Contents

Get Document Settings Example (VB.NET)

This example shows how to get various settings for a document.

'--------------------------------------------------------------------------------------- 
' Preconditions:
' 1. Read the SOLIDWORKS Document Manager API Getting Started 
'    topic and ensure that the required DLLs are registered.
' 2. Copy and paste this code into a VB.NET console application
'    in Microsoft Visual Studio.
' 3. Add the SolidWorks.Interop.swdocumentmgr.dll reference to the project:
'    a. Right-click the solution in Solution Explorer.
'    b. Select Add Reference
'    c. Click Browse.
'    d. Click install_dir\api\redist\SolidWorks.Interop.swdocumentmgr.dll.
'    e. Click Add.
'    f. Click Close.
' 4. Substitute path_to_SOLIDWORKS_2015_model with the path to a model that has been
'    saved in SOLIDWORKS 2015 or later. 

' 5. Substitute your_license_key with your SOLIDWORKS Document Manager 
'    license key.
' 6. Open the Immediate window.

' Postconditions: Examine the Immediate window.
'
' NOTE: Because the model is used elsewhere, do not save any changes.
'--------------------------------------------------------------------------------------- 
 
Imports SolidWorks.Interop.swdocumentmgr
Imports System
Imports System.Diagnostics
 
Module Module1
 
    Dim dmClassFact As SwDMClassFactory
    Dim dmDocMgr As SwDMApplication4
    Dim dmDoc As SwDMDocument19
    Dim dmDocType As SwDmDocumentType
    Dim status As SwDmDocumentOpenError
   
    Const docPath As String = "path_to_SOLIDWORKS_2015_model"
    Const licenseKey As String = "your_license_key"
 
    Sub main()
 
        dmClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory")
        dmDocMgr = dmClassFact.GetApplication(licenseKey)
        dmDoc = dmDocMgr.GetDocument(docPath, dmDocType, True, status)
 
        If Not (dmDoc Is NothingThen
            Debug.Print("Angular units: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsAngular))
            Debug.Print("Angular decimal places: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsAngularDecimalPlaces))
            Debug.Print("Decimal rounding: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsDecimalRounding))
            Debug.Print("Dual linear units: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsDualLinear))
            Debug.Print("Dual linear decimal display: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsLinearDecimalDisplay))
            Debug.Print("Dual linear decimal places: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsLinearDecimalPlaces))
            Debug.Print("Dual linear fraction denominator: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsDualLinearFractionDenominator))
            Debug.Print("Energy decimal places: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsEnergyDecimalPlaces))
            Debug.Print("Energy units: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsEnergyUnits))
            Debug.Print("Force units: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsForce))
            Debug.Print("Force decimal places: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsForceDecimalPlaces))
            Debug.Print("Linear units: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsLinear))
            Debug.Print("Linear decimal display: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsLinearDecimalDisplay))
            Debug.Print("Linear decimal places: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsLinearDecimalPlaces))
            Debug.Print("Linear fraction denominator: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsLinearFractionDenominator))
            Debug.Print("Mass prop decimal places: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsMassPropDecimalPlaces))
            Debug.Print("Mass prop length: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsMassPropLength))
            Debug.Print("Mass prop mass: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsMassPropMass))
            Debug.Print("Mass prop volume: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsMassPropVolume))
            Debug.Print("Power decimal places: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsPowerDecimalPlaces))
            Debug.Print("Power units: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsPowerUnits))
            Debug.Print("Time decimal places: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsTimeDecimalPlaces))
            Debug.Print("Time units: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsTimeUnits))
            Debug.Print("Unit system: " & dmDoc.GetSwDmSettingInteger(swDmDocumentUnitsIntegerValue_e.swDmUnitsUnitSystem))
 
            Debug.Print("Dual linear feet and inches format? " & dmDoc.GetSwDmSettingToggle(swDmDocumentUnitsToggle_e.swDmUnitsDualLinearFeetAndInchesFormat))
            Debug.Print("Dual linear round to nearest fraction? " & dmDoc.GetSwDmSettingToggle(swDmDocumentUnitsToggle_e.swDmUnitsDualLinearRoundToNearestFraction))
            Debug.Print("Linear feet and inches format? " & dmDoc.GetSwDmSettingToggle(swDmDocumentUnitsToggle_e.swDmUnitsLinearFeetAndInchesFormat))
            Debug.Print("Linear round to nearest fraction? " & dmDoc.GetSwDmSettingToggle(swDmDocumentUnitsToggle_e.swDmUnitsLinearRoundToNearestFraction))
 
        Else
            Debug.Print("Unable to open document. Check docPath variable.")
        End If
 
    End Sub
 
End Module



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Get Document Settings Example (VB.NET)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2022 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.