Hide Table of Contents

Get and Set Dimension Extension Lines Gaps (VBA)

This example shows how to get and set the gaps for the extension lines of a display dimension.

'--------------------------------------------------------------
' Preconditions:
' 1. Open public_documents\samples\tutorial\api\replaceview.slddrw.
' 2. Select a vertical edge in the model in DrawingView1.
'
' Postconditions:
' 1. Modifies the selected edge's dimension's line
'    extension gaps to the specified value.
' 2. Examine the drawing.
'
' NOTE: Because this drawing is used elsewhere, do not save
' changes.
'--------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDisplayDim As SldWorks.DisplayDimension
retBool as Boolean
Dim UseDoc As Boolean
Dim Gap As Double
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
 
    ' Programmatically add a dimension to the selected edge
    Set swDisplayDim = swModel.AddDimension2(0.07991695284535, 0.1237274983129, 0)    
    Debug.Print "Dimension Extension Lines"
    Debug.Print ""    
    ' Get document default value for extension lines' gaps
    Debug.Print "Value of document default gap:  " & swModel.GetUserPreferenceDoubleValue(swDetailingWitnessLineGap)    
    Debug.Print " "
    
    ' Get a dimension's extension line's gap
    retBool = swDisplayDim.GetWitnessLineGap(1, UseDoc, Gap)
    Debug.Print "Get Gap Operation:"
    Debug.Print "  Use document default for gap: " & UseDoc
    Debug.Print "  Gap value in system units:    " & Gap
    Debug.Print " "
    
    ' Set the dimension's extension line's gaps
    Gap = 0.005
    retBool = swDisplayDim.SetWitnessLineGap(0, False, Gap)
    retBool = swDisplayDim.SetWitnessLineGap(1, False, Gap)
    Debug.Print "Set Gap Operation: "
    Debug.Print "  Gap value in system units:    " & Gap
    Debug.Print " "
    
    ' Get the dimension's extension gap again
    retBool = swDisplayDim.GetWitnessLineGap(1, UseDoc, Gap)
    Debug.Print "Get Gap Operation:"
    Debug.Print "  Use document default for gap: " & UseDoc
    Debug.Print "  Gap value in system units:    " & Gap
    Debug.Print " "    
    swModel.GraphicsRedraw
End Sub


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 and Set Dimension Extension Lines Gaps (VBA)
*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) 2019 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.