Hide Table of Contents
SetUnits Method (IDisplayDimension)

Sets the unit display characteristics of this display dimension.

.NET Syntax

Visual Basic (Declaration) 
Function SetUnits( _
   ByVal UseDoc As Boolean, _
   ByVal UType As Integer, _
   ByVal FractBase As Integer, _
   ByVal FractDenom As Integer, _
   ByVal RoundToFraction As Boolean _
) As Integer
Visual Basic (Usage) 
Dim instance As IDisplayDimension
Dim UseDoc As Boolean
Dim UType As Integer
Dim FractBase As Integer
Dim FractDenom As Integer
Dim RoundToFraction As Boolean
Dim value As Integer
value = instance.SetUnits(UseDoc, UType, FractBase, FractDenom, RoundToFraction)
int SetUnits( 
   bool UseDoc,
   int UType,
   int FractBase,
   int FractDenom,
   bool RoundToFraction
int SetUnits( 
&   bool UseDoc,
&   int UType,
&   int FractBase,
&   int FractDenom,
&   bool RoundToFraction



True uses the document settings for units, false uses the setting values passed to the arguments (see Remarks)


Unit display setting as defined in swLengthUnits_e or swAngleUnits_e


Decimal or fraction display setting as defined in swFractionDisplay_e


Denominator for fraction display


True rounds values to the nearest fraction, false displays fractions only if the values are exact

Return Value

Return status (see Remarks)


The unit display settings of a display dimension are controlled by a value stored in one of two places: on the owning document, or on the individual display dimension. This method allows you to determine which setting to use, the document default or the values specified by UType, FractBase, FractDenom, and RoundToFraction.

If the UseDoc argument is True, then the display dimension unit information follows the document settings, and SolidWorks ignores the remainder of the arguments. SolidWorks also removes any local settings so that if you switch back to the local settings, they are set to default values.

The UType argument indicates the units. Depending on the type of dimension (angular or linear), this parameter takes a value from swLengthUnits_e or swAngleUnits_e. If the specified value is invalid, SolidWorks does not change the existing setting and returns an error in the return value.

The FractBase argument indicates whether the dimension is displayed as a fraction or a decimal. This must take a value from swFractionDisplay_e. SolidWorks displays this value as a fraction only if it can be precisely represented as a fraction based on the fraction denominator setting specified in FractDenom. However, if the RoundToFraction argument is True, SolidWorks forces fraction display by rounding the value to the nearest fraction.

The FractDenom argument indicates the fraction precision by specifying the largest fraction denominator used (for example, 4 for 1/4 or 32 for 1/32). Fraction display is valid only if UType is swINCHES or swFEETINCHES.

The return value indicates the success or failure of this function. It may take one of the following values:


Command failed because UType is invalid


Command failed for an unknown reason


Command was successful

After using this method, use IModelDoc2::GraphicsRedraw2 to redraw the graphics window to see your changes.


See Also


SolidWorks 99, datecode 1999207

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:   SetUnits Method (IDisplayDimension)
*   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.