Hide Table of Contents

Set and Get Maximum Extension Line Length Example (VBA)

This example shows how to set and get the maximum extension line length for a display dimension.

'--------------------------------------------
' Preconditions:
' 1. Open public_documents\samples\tutorial\lesson2\tutor1.sldprt.
' 2. Right-click Annotations and click Show Feature Dimensions.
' 3. Open the Immediate window.
'
' Postconditions:
' 1. Selects a dimension.
' 2. Sets the maximum length for the selected dimension's
'    witness extension lines to the specified value.
' 3. Examine the Immediate window.
'
' NOTE: Because the part is used elsewhere, do not save changes.
'--------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModelDoc As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swDisplayDim As SldWorks.DisplayDimension
Dim swModelView As SldWorks.ModelView
Dim selType As Long
Dim maxLineLength As Double
Dim status As Boolean
Dim rect As Variant
Sub main()
    Set swApp = Application.SldWorks
    Set swModelDoc = swApp.ActiveDoc
    Set swModelDocExt = swModelDoc.Extension
    Set swSelMgr = swModelDoc.SelectionManager
    status = swModelDocExt.SelectByID2("D2@Sketch2@tutor1.SLDPRT", "DIMENSION", 2.29248368227093E-03, 6.41116623573457E-02, 5.51580671328052E-02, False, 0, Nothing, 0)
    selType = swSelMgr.GetSelectedObjectType3(1, -1)
    If selType = swSelDIMENSIONS Then
      Set swDisplayDim = swSelMgr.GetSelectedObject6(1, -1)
      swDisplayDim.MaxWitnessLineLength = 130
   End If
   maxLineLength = swDisplayDim.MaxWitnessLineLength
   Debug.Print "New maximum witness extension line length: " & maxLineLength
      
   Set swModelView = swModelDoc.ActiveView
   Set rect = Nothing
   swModelView.GraphicsRedraw (rect)
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:   Set and Get Maximum Extension Line Length Example (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) 2021 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.