Hide Table of Contents
SetUnits2 Method (IDisplayDimension)

Sets the unit display characteristics of this display dimension.

.NET Syntax

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


True to use the document settings for units, false to use the setting values passed to this method (see Remarks)
Unit display setting as defined in swLengthUnits_e or swAngleUnits_e; valid only if UseDoc is false
Decimal or fraction display setting as defined in swFractionDisplay_e; valid only if UseDoc is false
Denominator for fraction display; valid only if UseDoc is false
True to round values to the nearest fraction, false to display fractions only if the values are exact; valid only if UseDoc is false
Decimal rounding as defined by swUnitsDecimalRounding_e; valid only if FractBase is swFractionDisplay_e.swDECIMAL and UseDoc is false

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: in the owning document or in 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, RoundToFraction, and DecimalRounding.

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

UType 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 this method returns an error.

FractBase indicates whether the dimension is displayed as a fraction or a decimal. SOLIDWORKS displays the dimension as a fraction only if it can precisely represent the dimension as a fraction based on the FractDenom setting. However, if the RoundToFraction argument is true, then SOLIDWORKS displays the dimension rounded to the nearest fraction.

FractDenom 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 method as follows:

If Return Value is... Then this method...
2 Failed because UType is invalid
1 Failed for an unknown reason
0 Succeeded

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


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:   SetUnits2 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) 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.