Cancel
Showing results for
Did you mean:

# Logic & functions ODD vs EVEN

Honored Contributor

Is there any way to identify odd vs even numbers within the variables? I looked at the built in functions and did not find anything that would help build up logic for Odd vs Even.

In specific what I'm working on is making a model for drawer packs. When a drawer is 16 or 17" deep, we use a 16" slide. When a drawer is 14 or 15" deep, we use a 14" slide, etc..

My goal is to automate hole positions relative to the front and back of the drawer, but cant find any logic that would help out that specific issue without manual input.

There are so many other variables involved in the task I really want to automate that one specific issue.

Edit- I may have figured it out. If I divide the number by 2, then use FIX to round down, that may get it done.

4 REPLIES

# Re: Logic & functions ODD vs EVEN

Gears Esteemed Contributor

@12GAGE, I don't understand the question or what you are trying to accomplish. Not sure why you need to differentiate odd and even variables for hole postions. Anyway, an illustration or example might be helpful.

Bruce Shand
ST10 MP7 - Insight - Win10 - K4200

# Re: Logic & functions ODD vs EVEN

Honored Contributor

I need to add 1" to a specific dimension when another dimension is odd.

Say X=12 to 36 in 1 inch increments

Y is 1.25 when X is even, Y is 2.25 when X is odd

X2=X/2

X3=Fix(X2)

X3=2*X3

X4=X-X3

Y=1.25+X4

is how I got it done. just figured it out.

The reason why and the specifics are very complex. The nutshell answer is I have a mechanical part that comes in 2" sizes where the parts that use it are 1" sizes.

# Re: Logic & functions ODD vs EVEN

Gears Esteemed Contributor

Hi 12 Gage,

without asking or understanding why and what the solution within Solid Edge would be as following:

I will split the solution into several steps, which are not necessary.

You can accomplish it in one step (formular) too:

1. define a help variable e.g. Xhelp1 = int(x/2)
2. then make another help variable Xhelp2 = 2*Xhelp1
This might either be equal X or one less X
3. Now You can use a kind of IF formular with following syntax for another helping variable let it call Yhelp  = -(Xhelp2=X)*1
This now either can be 1 for even or 0 for odd original variables
4. And this one could be added to Y bringing exactly what You requested

regards
Wolfgang

# Re: Logic & functions ODD vs EVEN

Honored Contributor

I agree the math could be condensed to a single line. But I was figuring it out and testing at the same time and only needed this for a single file. Was the path of least resistance.