IF THEN ELSE statement in Parameters?

IF THEN ELSE statement in Parameters?

Anonymous
Not applicable
4,859 Views
7 Replies
Message 1 of 8

IF THEN ELSE statement in Parameters?

Anonymous
Not applicable

Is it possible to put an IF THEN ELSE statement into the Parameters equation field? If so, could someone point me in the direction of how to parse it correctly because I can't seem to get it to work.

Thank you.

0 Likes
4,860 Views
7 Replies
Replies (7)
Message 2 of 8

philip1009
Advisor
Advisor

iLogic is your solution if you want to use Visual Basic code to regulate or automate Parameters.  Head over to the Inventor Customization forum for more help with this kind of task.  Other than that, let us know your workflow so we can help find the best solution for you, just make sure nothing you post or attach has anything confidential.

Message 3 of 8

SBix26
Consultant
Consultant

Can't be done directly, but with some clever tricks with supported functions you can put this logic into parameters.   Have a look at this posting from @ACEDeSmedt for some ideas.  There may be other posts along these lines, but my quick searching didn't spot them.


Sam B
Inventor Pro 2019.1.2 | Windows 7 SP1
LinkedIn

Message 4 of 8

mcgyvr
Consultant
Consultant

@Anonymous wrote:

Is it possible to put an IF THEN ELSE statement into the Parameters equation field? If so, could someone point me in the direction of how to parse it correctly because I can't seem to get it to work.

Thank you.


Can you provide an example of what you are trying to do?

 

You can do "IF" statements for feature suppression based on parameters without using ilogic through the feature properties..

IF.PNG



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 5 of 8

Anonymous
Not applicable

In the "Parameters" dialogue, under the User Parameter "HOLE_COUNT", I want to basically do this:

if Y_DIM<10 then (floor(d0 / d18) + 1 ul) else floor(d0 / d18)

 

Sorry that it's taken me so long to respond today; it's certainly been a Monday here.

0 Likes
Message 6 of 8

philip1009
Advisor
Advisor

On your Ribbon, go to Manage > iLogic > iLogic Browser, right click in the empty space of the browser and click Add Rule.  Name this Rule whatever you want and click OK.  Here's the code that would fit the scenario you provided:

 

SyntaxEditor Code Snippet

If Y_DIM < 10 Then
	HOLE_COUNT = Floor(d0 / d18) + 1
Else
	HOLE_COUNT = Floor(d0 / d18)
End If

  Save and close the rule.  Then back in your Manage > iLogic tab in your Ribbon, click on Event Triggers, in this window you can set a rule to automatically run when one of the triggers happens.  In this case, set the rule to run on Any Model Parameter Change.

Message 7 of 8

Anonymous
Not applicable

Thank you, Philip. I will give this a go when I get back into the office in the morning. Greatly appreciated.

0 Likes
Message 8 of 8

ACEDeSmedt
Advocate
Advocate

For the following statement:

parameter = Y_DIM<10 then (floor(d0 / d18) + 1 ul) else floor(d0 / d18)

 add this expression to the parameter:

parameter = floor(d0 / d18) + sign( 10 mm - Y_DIM )

You will need to specify the unit of '10' to match the unit of Y_DIM

 

sign() will output a 1 ul for every positive number and a 0 ul for not positive numbers (including 0)

=================================
If this is the solution, push the solution button 😉 (and maybe some kudos)
Autodesk Product Design Suit - Ultimate edition (Subscription)