Syntax For Unit Conversion

Syntax For Unit Conversion

Anonymous
Not applicable
693 Views
1 Reply
Message 1 of 2

Syntax For Unit Conversion

Anonymous
Not applicable

Hello All,

             I used this code to enter the inventor parameter as input from Visual Studio Community 2017.

             (     Code : partComDef.Parameters.Item("d0").Value = Convert.ToInt32(Txt_d0.Text)    )

In the TextBox, I can able to enter the value in "cm" units only. 

But I have an angle parameter, So I have to enter the value in "Degree / Radian" units only.

There is also no conversion from  "cm" to "deg/rad".

I need solution , It may be any syntax for unit conversion or Variable declaration

Please try to help me ASAP. 

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

_dscholtes_
Advocate
Advocate
Accepted solution

Apart from setting a value, you can also set a parameter's expression:

partComDef.Parameters.Item("d0").Expression = "15 deg"

and since you mention a text box:

partComDef.Parameters.Item("d0").Expression = "YourTextBox".Text

Just make sure you set a valid expression.

Must read:  Autodesk University DE101-1: Inventor API: Exploring iProperties and Parameters. You can find a link to this paper (including example code)  in this blogpost: https://modthemachine.typepad.com/my_weblog/2008/12/after-autodesk-university.html 


Inventor's internal units are: Centimeters (Length), Radians (Angle), Second (Time) and Kilogram (Mass).
Conversion is also briefly mentioned in above paper, I believe, or you could search the help section or this forum for the "UnitsOfMeasure" object which can be used to convert between units.

0 Likes