Verify parameter type in iLogic rule

Verify parameter type in iLogic rule

Anonymous
Not applicable
1,247 Views
4 Replies
Message 1 of 5

Verify parameter type in iLogic rule

Anonymous
Not applicable

Is there a possibility to check which type is a current parameter? For example I want to loop through some parameters and perform some actions depending on which types they are - Numerical, Text or Boolean. Below is something what I need to achieve:

 

If oCurrentParameter.ParamterType = Numerical Than

          ' perform some actions

ElseIf oCurrentParameter.ParameterType = Boolean Than

          ' perform some actions

Else ' Text

          ' perform some actions

End If

 

This is of course something like dumb-code but I hope that you understand what I am looking for.

0 Likes
Accepted solutions (1)
1,248 Views
4 Replies
Replies (4)
Message 2 of 5

YuhanZhang
Autodesk
Autodesk
Accepted solution

Here is a sample iLogic code to tell which type of the parameter(D1 is a parameter name) is:

 

	If (Parameter.Param("D1").Units = "Text") Then
		MsgBox("Text param")
	Else If (Parameter.Param("D1").Units = "Boolean") Then
		MsgBox("Boolean param")
	Else
		MsgBox ("Numerical param")
	End If

 

 

Hope it helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 5

Anonymous
Not applicable

Thanks @YuhanZhang. Your solution is great. I have last question and that will be all for this topic.

 

How can we check numerical parameter directly? In your solution we are dealing with it using Else statement. What should I type in If statement? I tried with Parameter.Param("D1").Units = "Numerical" and Parameter.Param("D1").Units = "Numeric" without any result.

0 Likes
Message 4 of 5

YuhanZhang
Autodesk
Autodesk

As you know that currently Inventor supports three types parameters(Text, Boolean and Numerical), the Parameter.Units returns the "Text" for text parameter, "Boolean" for Boolean parameter, but a detailed unit(like in/ft etc.) for numerical parameter, so the logic in the sample code just makes use of this, so if a parameter is not Text/Boolean parameter then it is a numerical parameter. Hope this clears.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 5 of 5

Anonymous
Not applicable

Thank you @YuhanZhang

 

Now everything is clear for me.

0 Likes