iLogic To Create Custom Parameters That Match User Defined Parameters

iLogic To Create Custom Parameters That Match User Defined Parameters

fsnyderE8767
Enthusiast Enthusiast
768 Views
3 Replies
Message 1 of 4

iLogic To Create Custom Parameters That Match User Defined Parameters

fsnyderE8767
Enthusiast
Enthusiast

Hi,

 

I'm not sure if i am going about this the correct way, but what I am trying to do is create a custom TEXT property that matches the value of a user defined property.

 

Say I have a property called "Force_Extend" and it's values are 4000 lbforce, but I want to make a custom text property without the underscore called "Force Extend."  If I do the following code 

iProperties.Value("Custom", "Force Extend") = Parameter("Force_Extend")

 and then open the properties, it created a new property called "Force Extend" but the value is not 4,000 and it is not Text.  The value is a crazy number 1544354.3307086611 and the type is Number.

 

Is there a way to make the "Force Extend" custom property say 4000 as a Text type?

0 Likes
Accepted solutions (1)
769 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor

If you want to use iLogic for this, you need to convert internal value to the required units.

 

 

'Get parameter value in internal units
' iLogic
'Dim forceExtendValueInDbUnits = Parameter.Param("Force_Extend").Value
' Standard API
Dim part As PartDocument = ThisDoc.Document
Dim forceExtendValueInDbUnits = part.ComponentDefinition.Parameters("Force_Extend").Value

'Convert value to required units. Internal units for force is "kg*cm/s/s"
Dim forceExtendValueInLbforce = ThisDoc.Document.UnitsOfMeasure.ConvertUnits(forceExtendValueInDbUnits, "kg*cm/s/s", "lbforce")

'Use result
Logger.Debug(forceExtendValueInLbforce)
iProperties.Value("Custom", "ForceExtend") = forceExtendValueInLbforce.ToString()

 

 

0 Likes
Message 3 of 4

fsnyderE8767
Enthusiast
Enthusiast

Thanks Michael, that worked great!  I'll be honest, I kind of understand what you did, but where did the kg*cm/s/s come from?  I would like to have this same rule done to convert PSI to text as done with the lbforce but I'm lost on to how you started with those units.  

0 Likes
Message 4 of 4

Michael.Navara
Advisor
Advisor
Accepted solution

This strange units becomes from definition of basic unit for force Newton (N) and units used internally in Inventor.

N = kg * m * s-2 because Inventor uses internal unit for length centimeter, you can construct the internal unit for force as kg * cm * s-2 and because you can't use power in units definition you get kg*cm/s/s.

 

The same you can do for psi. Pressure is defined as psi = lbforce/in2. In SI units it is Pa = N/m2 => internal units for pressure is kg/cm/s/s.

 

0 Likes