"IF" Statement in "Equation" Cells in Parameter Dialogue

"IF" Statement in "Equation" Cells in Parameter Dialogue

BeKirra
Advisor Advisor
551 Views
15 Replies
Message 1 of 16

"IF" Statement in "Equation" Cells in Parameter Dialogue

BeKirra
Advisor
Advisor

Is it possible to insert "IF" statement in the equation cell (see below - it can be an IPT/IAM file)?

Here is an example.

If "d0" > 20, then "d1" = 10, otherwise "d1" = 5

I've tried but no success.

(BTW I am not trying to create an ipart.)

 

Thanks In advance.

 

BeKirra_0-1744027935264.png

 

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
552 Views
15 Replies
Replies (15)
Message 2 of 16

kacper.suchomski
Mentor
Mentor

Hi

You can do this via iLogic.


Kacper Suchomski

EESignature


YouTube - Inventor tutorials | WWW | LinkedIn | Instagram

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 3 of 16

BeKirra
Advisor
Advisor

So "IF" statement won't work in equation cell?

For a simple task I don't prefer using iLogic.

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
Message 4 of 16

pcrawley
Advisor
Advisor

No, there is no "If" in the parameters dialogue box.  I understand not wanting to use iLogic for "a simple task", but sometimes, it really is the "simplest" solution:

If d0 > 20 Then
	d1 = 10
	Else
	d1 = 5	
End If

 

Because the iLogic is code operates on parameters, you don't need any special triggers - it just works.

Peter
Message 5 of 16

johnsonshiue
Community Manager
Community Manager

Hi! This is a very interesting request. Certainly, a simple iLogic rule as Peter mentioned above will work. There are other ways to solve it. Here is a solution by using parametric functions, which will lead to the logical result. Please note that when d0 = 20.00001mm, the result will be zero, which wrong. But I don't believe anybody would add have such dimension.

 

sign(( d0 - 20.00001 mm ) / 1 mm) * 10 mm + sign(( 20.00001 mm - d0 ) / 1 mm) * 5 mm

 

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 6 of 16

pcrawley
Advisor
Advisor

Genius (as usual) @johnsonshiue !

Peter
0 Likes
Message 7 of 16

NachoShaw
Advisor
Advisor

I'm going to chime in here, hi Johnson 🙂

 

IF in equations makes sense, I common topic among users. Why is iLogic not the preferred choice? While iLogic is ok, there are some company policies the do not permit code,especially when iLogic remains unprotected. ILogic makes it hard to share files with a function dependency so code share persists.

 

All that's needed if the inclusion of 'IF'

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 8 of 16

BeKirra
Advisor
Advisor

Thanks to @pcrawley and @johnsonshiue 

Both your codes work.

But it is not what I am after.

 

Edit: @johnsonshiue 

Sorry, I mentioned your method is not what I am after because your equation is a bit of complicate.

 

@NachoShaw Thanks for your input.

I agree with your comment.

👍

 

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
Message 9 of 16

johnsonshiue
Community Manager
Community Manager

Hi Folks,

 

Certainly, having the ability to set logical statement in a parametric expression makes perfect sense. But it always comes down to the cost and the priority. Nothing is free. Please feel free to submit it to Inventor Ideas forum (https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232) so that the users can vote for it. The project teams will review and prioritize it accordingly.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 10 of 16

NachoShaw
Advisor
Advisor

We don't expect it to be free which is why we all pay a subscription 😎

 

It already exists in the ideas station

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 11 of 16

johnsonshiue
Community Manager
Community Manager

Hi Nacho,

 

The "free" I am talking about is the cost to implementing such workflow. Though it might seem "easy" to implement, it can lead to costly technical implications.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 12 of 16

BeKirra
Advisor
Advisor

@johnsonshiue wrote:

Hi Folks,

 

Certainly, having the ability to set logical statement in a parametric expression makes perfect sense. But it always comes down to the cost and the priority. Nothing is free.

...


Understand and agree.

When Inventor updates or new release come out for install, it obviously costed to Autodesk's implement.

But updating and upgrading Inventor is how Autodesk is to keep it's users.

 

As a user, I personally expect to get samll functions like this one added in or improved before next release.

 

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
Message 13 of 16

johnsonshiue
Community Manager
Community Manager

Hi! Submitting these ideas to Inventor Ideas forum or participating in the Inventor Feedback Community is the best way to escalate the need.

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 14 of 16

J-Camper
Advisor
Advisor

This is a bit more simplified version of @johnsonshiue , equation:

5 mm + 5 mm * sign(floor(d0 / 20 mm))

Or this if your step size will always be 5mm:

5 mm * ( 1 ul + sign(floor(d0 / 20 mm)) )

Then you can create sudo Else If statements like this:

5 mm * ( 1 ul + sign(floor(d0 / 20 mm)) + sign(floor(d0 / 40 mm)) + sign(floor(d0 / 60 mm)) )


The sign operator feels very much like an If operator in this case.


Edit:
I just realized you were asking for greater than 20 mm not greater than or equal to 20mm.  The floored division above will do greater than or equal to.  A simple subtraction will do greater than:

5 mm * ( 1 ul + sign(d0 - 20 mm) )

 

 

Message 15 of 16

NachoShaw
Advisor
Advisor

Be sure to use ABS(Sign) as I've had negative value instances using Sign in the past

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 16 of 16

J-Camper
Advisor
Advisor

Interesting.  The documentation for Sign that I have read seems like it should be a purely binary output [Functions, prefixes, and algebraic operators].  Do you have an example of any outcome that is not a 1 or 0?

0 Likes