IF statements, even or odd values

Fully_Defined
Collaborator
Collaborator

IF statements, even or odd values

Fully_Defined
Collaborator
Collaborator

I don't see any mention of how Fusion treats even/odd values in IF statements, here. Am I looking in the wrong place?

 

I need a parameter for a feature pattern that offsets the seed to a different location depending on if it has an even or odd number of instances along a particular axis.

 

I am aware that there are alternative (possibly better!) means to the same end, but this question is about even and odd values in IF statements. I just want to know if there is an intended workflow or workaround to use it in logic in Fusion.

 

Are there more operators than what is shown in the link above?

0 Likes
Reply
Accepted solutions (3)
542 Views
7 Replies
Replies (7)

jhackney1972
Consultant
Consultant
Accepted solution

Take a look at this model where I determine the placement of partitions using a test for even or odd on the partition placement.  If the placement is even, the Joint Offset value is applied, if it is odd, it is not.  I too could not find an direct statement to determine even or odd so I created a little test then applied the test to an If statement.  There are two of these tests in the model, one for each partition direction.  Model is attached.

 

Even or Odd.jpg

 

 

John Hackney, Retired
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.

EESignature

1 Like

Fully_Defined
Collaborator
Collaborator

I like this. If after the value is divided by two and rounded up, and the rounding figure is larger than the original figure divided by two, then it is odd. That works well for whole integers, which is all I would use for a number of instances in a pattern.

 

Thumbs up!

 

My fear was that null values for length isn't allowed in Fusion, but you clearly are using it here. Nice!

 


@jhackney1972 wrote:

Take a look at this model where I determine the placement of partitions using a test for even or odd on the partition placement.  If the placement is even, the Joint Offset value is applied, if it is odd, it is not.  I too could not find an direct statement to determine even or odd so I created a little test then applied the test to an If statement.  There are two of these tests in the model, one for each partition direction.  Model is attached.

 

Even or Odd.jpg

 

 


 

0 Likes

g-andresen
Consultant
Consultant
Accepted solution

Hi,

This also works if modulo is not known.

value_even_odd.png

günther

1 Like

Fully_Defined
Collaborator
Collaborator

@g-andresen wrote:

Hi,

This also works if modulo is not known.

value_even_odd.png

günther


This is also good. Thanks!

 

In the meantime, I found this, which is a lot more information than the page I linked to originally.

0 Likes

MRWakefield
Advisor
Advisor
Accepted solution

You could use the "Modulo" operator with a value of "2" as the divisor:

 

MRWakefield_0-1720304651203.png

 

If this answers your question please mark the thread as solved as it can help others find solutions in the future.
Marcus Wakefield

___________________________________________________________________________________________________________
I've created a Windows application for creating custom thread files for Fusion. You can find out about it here. Hope you find it useful.
___________________________________________________________________________________________________________

2 Likes

Fully_Defined
Collaborator
Collaborator

This was the answer I was looking for. Thanks!

 

Screenshot 2024-07-06 at 16.06.03.pngScreenshot 2024-07-06 at 16.05.18.png

 


@MRWakefield wrote:

You could use the "Modulo" operator with a value of "2" as the divisor:

 

MRWakefield_0-1720304651203.png

 


 

0 Likes

MRWakefield
Advisor
Advisor

I'm pleased it worked for you 😀

If this answers your question please mark the thread as solved as it can help others find solutions in the future.
Marcus Wakefield

___________________________________________________________________________________________________________
I've created a Windows application for creating custom thread files for Fusion. You can find out about it here. Hope you find it useful.
___________________________________________________________________________________________________________

0 Likes