Hide Table of Contents
AddDimension2 Method (IModelDoc2)

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

.NET Syntax

Visual Basic (Declaration) 
Function AddDimension2( _
   ByVal X As Double, _
   ByVal Y As Double, _
   ByVal Z As Double _
) As Object
Visual Basic (Usage) 
Dim instance As IModelDoc2
Dim X As Double
Dim Y As Double
Dim Z As Double
Dim value As Object
value = instance.AddDimension2(X, Y, Z)
object AddDimension2( 
   double X,
   double Y,
   double Z
Object^ AddDimension2( 
&   double X,
&   double Y,
&   double Z


Dimension text location in meters
Dimension text location in meters
Dimension text location in meters

Return Value

Newly created dimension



sYou should only use this method on the visible document. Before using this method, you can check to see if the document is visible by using ISldWorks::Visible.

Dimensions are created based on selection location. For example, creating an angular dimension between two lines gets different results based on which line endpoints are selected. Therefore, if you are using IModelDocExtension::SelectByID2 to select the entities for dimensioning, then you should specify the XYZ selection coordinates. You must also leave the object name argument empty, because if you pass the object name to IModelDocExtension::SelectByID2, then the selection routines tries to locate that item without using the coordinates.

Because coordinates are ignored when the object name is passed, the dimensioning routines are not able to use a specific selection location for the dimension. This causes unpredictable results in your dimension creation because you cannot be sure which line endpoint is selected by IModelDocExtension::SelectByID2.

When you use this method, you might also want to use ISldWorks::SetUserPreferenceToggle swInputDimValOnCreate to suppress the dialog box that lets the user enter the dimension value.


See Also


SolidWorks 2001Plus FCS, Revision Number 10.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:   AddDimension2 Method (IModelDoc2)
*   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) 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.