Hide Table of Contents

Add Along Y Dimension to 3D Sketch Example (VB.NET)

This example shows how to add a display dimension along the y axis in a 3D sketch.


' Preconditions:

'   1. Open SolidWorks.

'   2. Verify the location of the part template.


' Postconditions:

'   1. Click the green check mark in the Modify dimension dialog

'      (look for the hidden dialog behind your other windows).

'   2. 3DSketch1 is in edit mode and contains a spline and a corner rectangle.

'   3. The display dimension of 63.238 mm appears on the y axis starting at

'      (-0.1, 0, 0.01111142101618) while the sketch is in edit mode.


Imports SolidWorks.Interop.sldworks

Imports SolidWorks.Interop.swconst

Imports System

Partial Class SolidWorksMacro

    Dim Part As ModelDoc2

    Dim myDisplayDim As DisplayDimension

    Dim boolstatus As Boolean

    Dim longstatus As Long

    Sub main()

        boolstatus = swApp.ResetUntitledCount(0, 0, 0)

        Part = swApp.NewDocument("C:\Documents and Settings\All Users\Application Data\SolidWorks\SolidWorks 2010\templates\Part.prtdot", 0, 0, 0)

        swApp.ActivateDoc2("Part1", False, longstatus)

        Part = swApp.ActiveDoc


        Dim vSkLines As Object

        vSkLines = Part.SketchManager.CreateCornerRectangle(-0.05171778666374, 0.01933785938058, 0.03, 0.08445537697179, -0.04142795937025, -0.03)

        boolstatus = Part.Extension.SelectByID2("Right Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)


        Dim pointArray As Object

        Dim points(11) As Double

        points(0) = 0

        points(1) = -0.03591009660795

        points(2) = 0.04608246573503

        points(3) = 0

        points(4) = 0.0147420284178

        points(5) = 0.005170989573514

        points(6) = 0

        points(7) = -0.006478053228363

        points(8) = -0.04282131900055

        points(9) = 0

        points(10) = -0.02294509596464

        points(11) = -0.09396066420243

        pointArray = points

        Dim skSegment As SketchSegment

        skSegment = Part.SketchManager.CreateSpline2((pointArray), True)


        boolstatus = Part.Extension.SelectByID2("3DSketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)


        boolstatus = Part.Extension.SelectByID2("Point5", "SKETCHPOINT", 0, -0.03591009660795, 0.04608246573503, False, 0, Nothing, 0)

        boolstatus = Part.Extension.SelectByID2("Point4", "SKETCHPOINT", 0.08445537697179, 0.02732744880518, -0.01872625210654, True, 0, Nothing, 0)

        myDisplayDim = Part.SketchManager.AddAlongYDimension(-0.1, 0, 0.01111142101618)




    End Sub

    Public swApp As SldWorks

End Class

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

Subject:   Feedback on Help Topics
Page:   Add Along Y Dimension to 3D Sketch Example (VB.NET)
*   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:


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

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.