Unit Of Measure

Unit Of Measure

jpchaisson
Advocate Advocate
809 Views
3 Replies
Message 1 of 4

Unit Of Measure

jpchaisson
Advocate
Advocate

im trying to draw a sketch line and when my code is ran it draws the line but in cm not inches. heres my code...

 

Dim oLines(0 To 3) AsSketchLine

oLines(0) = oSketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(0, 0), oTG.CreatePoint2d(0, 2))

 

 

when this runs i have a line thats 0.7874 inches, instead of 2 inches. how do i set the UOM so inventor knows i mean inches?

0 Likes
810 Views
3 Replies
Replies (3)
Message 2 of 4

nmunro
Collaborator
Collaborator
All lengths in Inventor are stored internally as cm, all angles as radians. The UnitsOfMeasure object contains plenty of methods to do things like convert values between units. Check out the help file, it provides very good information and some samples.

        


https://c3mcad.com

0 Likes
Message 3 of 4

jpchaisson
Advocate
Advocate

I have done that and tried many things but i get errors .

0 Likes
Message 4 of 4

nmunro
Collaborator
Collaborator

Here is a generic example of how you might use one of the methods in the UnitsOfMeasure object to get what you are after.

 

 

' Get UOM object from the document with something like

Dim uom As UnitsOfMeasure

uom = <doc>.UnitsOfMeasure


' Get converted value (does not have to be done outside of AddByTwoPoints call, just for clarity sakes

Dim maxY As Double

' Convert 2" to cm (database length units)

maxY = uom.ConvertUnits(2.0, UnitsTypeEnum.kInchLengthUnits, UnitsTypeEnum.kDatabaseLengthUnits)

 

' Call the line creation method with the value converted to the required cm's

Dim oLines(0 To 3) As SketchLine

oLines(0) = oSketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(0, 0), oTG.CreatePoint2d(0, maxY))

 

 

Neil

        


https://c3mcad.com

0 Likes