Hide Table of Contents

Autodimension Selected Drawing View Example (VBA)

This example shows how to autodimension a selected drawing view.

 

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

'

' Preconditions: Drawing document of a part is open and

'                a drawing view is selected.

'

' Postconditions: Supported entities in the selected drawing

'                view are autodimensioned.

'

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

Option Explicit

 

Const swAutodimEntitiesBasedOnPreselect = 0

 

Sub main()

 

    Dim swApp As SldWorks.SldWorks

    Dim myModel As SldWorks.ModelDoc2

    Dim myDrawing As SldWorks.DrawingDoc

    Dim boolstatus As Boolean

    Dim longstatus As Long

    Dim selmark As Long

    Dim nocallout As SldWorks.Callout

    Dim options As Long

    Dim entsToDim As Long, hscheme As Long, hplace As Long, vscheme As Long, vplace As Long

 

    Set swApp = Application.SldWorks

    Set myModel = swApp.ActiveDoc

    Set myDrawing = myModel

 

    myModel.ClearSelection2 True

 

    ' View to be autodimensioned must be selected, no special mark necessary

    options = 0

    selmark = 0

 

    ' Horizontal and vertical datum, or a vertex datum, baselines for dimension creation.

    ' These are optional; if not selected, autodimension uses default datums,

    ' the leftmost and bottom-most edges.

    selmark = SwConst.swAutodimMark_e.swAutodimMarkHorizontalDatum

    

    selmark = SwConst.swAutodimMark_e.swAutodimMarkVerticalDatum

 

    selmark = SwConst.swAutodimMark_e.swAutodimMarkOriginDatum

 

    ' Select a vertex on the part in the selected drawing view

    boolstatus = myModel.Extension.SelectByID2("", "VERTEX", 0.03, 0.034, 0#, True, selmark, nocallout, options)

 

    entsToDim = swAutodimEntitiesBasedOnPreselect  ' New enum value?

    selmark = 0

 

    hscheme = SwConst.swAutodimScheme_e.swAutodimSchemeBaseline

    hplace = SwConst.swAutodimHorizontalPlacement_e.swAutodimHorizontalPlacementAbove

    vscheme = SwConst.swAutodimScheme_e.swAutodimSchemeBaseline

    vplace = SwConst.swAutodimVerticalPlacement_e.swAutodimVerticalPlacementRight

    longstatus = myDrawing.AutoDimension(entsToDim, hscheme, hplace, vscheme, vplace)

 

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:   Autodimension Selected Drawing View 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) 2012 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.