Hide Table of Contents

Isolate Changed Dimension (VB.NET)

This example shows how to isolate a changed dimension.

'------------------------------------------------------
' Preconditions: The specified drawing and part
' documents exist.
'

' Postconditions:
' 1. Opens the drawing document.
' 2. Sets the system option to display
'    changed dimensions in the color selected
'    for Tools > Options > System Options >
'    Colors > Color scheme settings >
'    Drawings, Changed dimensions
.
' 3. Saves and closes the drawing document.
' 4. Opens the part document of the drawing document.
' 5. Changes a dimension.
' 6. Saves and closes the part document.
' 7. Opens the previously saved drawing document.
' 8. Examine the drawing document to verify that
'    the changed dimension is displayed in the
'    
changed-dimension color. Place your cursor over
'    
the dimension to see its previous value.
'-------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System

Partial Class SolidWorksMacro

    
Public Sub Main()

        
Dim swModel As ModelDoc2
        
Dim swModelDocExt As ModelDocExtension
        
Dim swDrawing As DrawingDoc
        
Dim fileName As String
        Dim saveFileName As String
        Dim errors As Long
        Dim warnings As Long
        Dim status As Boolean

        ' Open drawing document
        fileName = "install_dir\samples\tutorial\api\box.slddrw"
        swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocDRAWING, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)

        
' Isolate changed dimensions
        ' Equivalent to selecting Tools > Options > System Options > Colors >
        ' Use specified color for changed drawing dimensions on open
        swApp.SetUserPreferenceToggle(swUserPreferenceToggle_e.swUseChangedDimensions, True)
        swDrawing = swModel
        swDrawing.IsolateChangedDimensions()

        
' Save drawing document to another name
        saveFileName = "install_dir\samples\tutorial\api\box_changed.slddrw"
        swModelDocExt = swModel.Extension
        status = swModelDocExt.SaveAs(saveFileName, swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_e.swSaveAsOptions_Silent,
Nothing, errors, warnings)
        swApp.CloseDoc(saveFileName)

        
' Open the part document referenced by the drawing document,
        ' change a dimension, and save the document
        fileName = "install_dir\samples\tutorial\api\box.sldprt"
        swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocPART, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)
        swModelDocExt = swModel.Extension
        status = swModelDocExt.SelectByID2(
"Sketch1", "SKETCH", 0, 0, 0, True, 0, Nothing, 0)
        status = swModelDocExt.SelectByID2(
"D2@Sketch1@box.SLDPRT", "DIMENSION", -0.03613329319351, -0.02215939491444, 0.02938582119709, True, 0, Nothing, 0)
        
Dim swDimension As Dimension
        swDimension = swModel.Parameter(
"D2@Sketch1")
        swDimension.SystemValue = 0.185
        swModel.ClearSelection2(
True)
        status = swModel.EditRebuild3()
        status = swModel.Save3(swSaveAsOptions_e.swSaveAsOptions_Silent, errors, warnings)
        swApp.CloseDoc(fileName)

        
' Open the previously saved drawing document
        ' and place your cursor on the changed dimension,
        ' which displays in the color specified for
        ' changed dimensions, to see its previous value
        swModel = swApp.OpenDoc6(saveFileName, swDocumentTypes_e.swDocDRAWING, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)
    
End Sub


    ''' <summary>
    ''' The SldWorks swApp variable is pre-assigned for you.
    ''' </summary>
    Public swApp As SldWorks


End Class



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:   Isolate Changed Dimension (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) 2015 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.