Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unit Of Measure

3 REPLIES 3
Reply
Message 1 of 4
jpchaisson
294 Views, 3 Replies

Unit Of Measure

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?

3 REPLIES 3
Message 2 of 4
nmunro
in reply to: jpchaisson

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

Message 3 of 4
jpchaisson
in reply to: nmunro

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

Message 4 of 4
nmunro
in reply to: jpchaisson

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report