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: Drawing document is open.

'                Drawing View1 contains a model.

'                Edge on that model is selected.

'

' Postconditions: The value of the selected edge's dimension's line

'                 extension gaps are modified to the specified

'                 value.

'-------------------------

Option Explicit

 

Dim swApp                       As SldWorks.SldWorks

Dim swModel                     As SldWorks.ModelDoc2

Dim swModelDocExt               As SldWorks.ModelDocExtension

Dim swSelMgr                    As SldWorks.SelectionMgr

Dim swDrawing                   As SldWorks.DrawingDoc

Dim swDisplayDim                As SldWorks.DisplayDimension

Dim boolstatus                  As Boolean

Dim longstatus                  As Long, longwarnings As Long

Dim UseDoc                      As Boolean

Dim retBool                     As Boolean

Dim Gap                         As Double

 

Sub main()

 

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set swSelMgr = swModel.SelectionManager

Set swDrawing = swModel

 

' Make Drawing View1 active

boolstatus = swDrawing.ActivateView("Drawing View1")

 

' 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) 2013 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.