Hide Table of Contents
AddDimension Method (IModelDocExtension)

Creates a display dimension at the specified location for selected entities.

.NET Syntax

Visual Basic (Declaration) 
Function AddDimension( _
   ByVal X As System.Double, _
   ByVal Y As System.Double, _
   ByVal Z As System.Double, _
   ByVal Direction As System.Integer _
) As System.Object
Visual Basic (Usage) 
Dim instance As IModelDocExtension
Dim X As System.Double
Dim Y As System.Double
Dim Z As System.Double
Dim Direction As System.Integer
Dim value As System.Object
value = instance.AddDimension(X, Y, Z, Direction)
System.object AddDimension( 
   System.double X,
   System.double Y,
   System.double Z,
   System.int Direction
System.Object^ AddDimension( 
&   System.double X,
&   System.double Y,
&   System.double Z,
&   System.int Direction


X coordinate of display dimension text
Y coordinate of display dimension text
Z coordinate of display dimension text
Direction of dimensioning extension line or rapid dimensioning quadrant as defined in swSmartDimensionDirection_e (see Remarks)

Return Value




The X, Y, and Z coordinates of the display dimension text must be appropriate for the specified Direction, or this method fails to add the display dimension.

For parts, Direction specifies the dimensioning manipulator direction that appears in the user interface when an extension line is needed to unambiguously define what to dimension.

For drawings, Direction specifies the rapid dimensioning selector quadrant to which to add the display dimension.

Before calling this method, you must select the entities for which to add a display dimension. Entities must be selected by location and not name. If you specify line names instead of coordinates, the dimensioning routines randomly pick locations on the lines, which can yield unpredictable results during angular dimension creation.

For example, to create an angular dimension between two lines:

  1. Call IModelDocExtension::SelectByID2 to select a sketch segment of the angle you want to dimension, specifying the line's X, Y, and Z coordinates.
  2. Call IModelDocExtension::SelectByID2 to select the vertex of the angle you want to dimension, specifying the vertex's X, Y, and Z coordinates.
  3. Call this method, specifying the X, Y, Z coordinates of the display dimension text and the Direction of the extension line that is needed to unambiguously define the angle to dimension.

If the pre-selected entities unambiguously define what you wish to dimension, then no extension lines are needed. In that case, call IModelDoc2::AddDimension2 instead of this method.

NOTE: To change the angle in an angular dimension to its supplementary angle, use IDisplayDimension::SupplementaryAngle.

You should only use this method on visible documents. Before using this method, use ISldWorks::Visible to check whether a document is visible.

Before calling this method, you might want to call ISldWorks::SetUserPreferenceToggle with swUserPreferenceToggle_e.swInputDimValOnCreate to suppress the dialog box that allows the user to type the dimension value.


See Also


SOLIDWORKS 2015 FCS, Revision Number 23.0

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:   AddDimension Method (IModelDocExtension)
*   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) 2022 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.