Use iLogic to Change Units of a Parameter

Use iLogic to Change Units of a Parameter

Anonymous
Not applicable
2,543 Views
1 Reply
Message 1 of 2

Use iLogic to Change Units of a Parameter

Anonymous
Not applicable

I have a user parameter that will sometimes be in inches and sometimes in square inches based on the type of part it is. I want to make a rule that will change the unit type of this one parameter from "in" to "in^2" or vise versa based on certain conditions. What is the iLogic code I can use to change the parameter unit type?

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

Anonymous
Not applicable
Accepted solution

'Get the Parameters Object. Assumes a Part or Assembly document as active
Dim oParams As parameters
oParams = ThisDoc.Document.ComponentDefinition​.Parameters

 

'Get the Parameter required
Dim oParamName As Parameter
oParamName = oParams.Item("d0") 'Replace d0 with the name of your parameter

 

'Change the units of parameter
If condition = 1 Then
      oParamName.Units = "in"
Else
      oParamName.Units = "in^2"
End If

 

'Update document
ThisDoc.Document.Update