Hide Table of Contents

Create Full Symmetrical Angular Dimension Example (VBA)

This example shows how to create a full symmetrical angular dimension between a centerline and a line.

'---------------------------------------------------------
' Preconditions: Verify that the specified part document template
' exists.
'
' Postconditions:
' 1. Opens a new part document.
' 2. Opens a sketch.
' 3. Creates a centerline and three lines in
'    the open sketch.
' 4. Selects the centerline and one of the lines.
' 5. Suppresses the dimension dialog.
' 6. Creates a full symmetrical angular dimension for
'    the entities selected in step 4.
' 7. Unsuppresses the dimension dialog.
' 8. Examine the graphics area to verify step 6.
'----------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSketchMgr As SldWorks.SketchManager
Dim swSketchSegment As SldWorks.SketchSegment
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swDisplayDimension As SldWorks.DisplayDimension
Dim status As Boolean
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.NewDocument("C:\ProgramData\SolidWorks\SolidWorks 2015\templates\Part.prtdot", 0, 0, 0)

    'Sketch a centerline and three lines
    Set swSketchMgr = swModel.SketchManager
    swSketchMgr.InsertSketch (True)
    Set swSketchSegment = swSketchMgr.CreateCenterLine(0#, 0.043667, 0#, 0#, -0.050556, 0#)
    Set swSketchSegment = swSketchMgr.CreateLine(-0.102, 0.039667, 0#, -0.086223, 0.011, 0#)
    Set swSketchSegment = swSketchMgr.CreateLine(0.142445, 0.066556, 0#, 0.100889, -0.032333, 0#)
    Set swSketchSegment = swSketchMgr.CreateLine(0.085334, 0.036556, 0#, 0.049658, -0.048341, 0#)    
    'Select the centerline and one of the lines
    Set swModelDocExt = swModel.Extension
    status = swModelDocExt.SelectByID2("Line1", "SKETCHSEGMENT", -2.22223294397278E-04, 2.23334410869282E-02, 0, False, 0, Nothing, 0)
    status = swModelDocExt.SelectByID2("Line3", "SKETCHSEGMENT", 0.113556103437018, -1.44445141358242E-03, 0, True, 0, Nothing, 0)
    swModel.ClearSelection2 True
    'Suppress the dimension dialog box
    swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swInputDimValOnCreate, False    
    'Create a full symmetrical angular dimension
    status = swModelDocExt.SelectByID2("Line1", "SKETCHSEGMENT", -2.22223294397278E-04, 2.23334410869282E-02, 0, False, 0, Nothing, 0)
    status = swModelDocExt.SelectByID2("Line3", "SKETCHSEGMENT", 0.113556103437018, -1.44445141358242E-03, 0, True, 0, Nothing, 0)
    Set swDisplayDimension = swModelDocExt.AddSymmetricDimension(8.32913738352659E-02, 0.112403597688285, 0)
    swModel.ClearSelection2 True    
    'Unsuppress the dimension dialog box
    swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swInputDimValOnCreate, True    
    swModel.ViewZoomtofit2
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:   Create Full Symmetrical Angular Dimension 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) 2016 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.