Units of Measure

Units of Measure

NachoShaw
Advisor Advisor
1,876 Views
1 Reply
Message 1 of 2

Units of Measure

NachoShaw
Advisor
Advisor

Hey

 

I am using a routine that gets a range box size and the return value is in the default unit of CM. We use 2 types of formats (in. for USA and mm for Aus).

 

I have looked at trying to use the document Units of Measure but all it really does is return the suffix format.

 

how can I convert it using the UOM so that the return value matches the current format of the document i.e. inches or mm?

 

thanks

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Accepted solutions (1)
1,877 Views
1 Reply
Reply (1)
Message 2 of 2

YuhanZhang
Autodesk
Autodesk
Accepted solution

Here is a sample VBA to show how to convert the length value(in centimeters as default) to the document length units:

 

Sub ConvertValueToDocUnits()
    ' say you have a double value(in centimeters)
    Dim dRangeBoxVal As Double
    dRangeBoxVal = 2.54
    
    Dim oUOM As UnitsOfMeasure
    Set oUOM = ThisApplication.ActiveDocument.UnitsOfMeasure

    Dim dResultVal As Double
    dResultVal = oUOM.ConvertUnits(dRangeBoxVal, kCentimeterLengthUnits, oUOM.LengthUnits)
    
    Debug.Print dResultVal & " " & oUOM.GetStringFromType(oUOM.LengthUnits)
End Sub

Hope it helps.

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.