Odd or Even Equation

Hi,

I've just spent a wee while trying to find a way of setting adimension based on whether a global variable is either odd or even.It took me a while, and since I don't know VB I didn't know theanswer, so I thought I would share it here, just in case someoneelse is in the same predicament!

Basically, I have a variable that sets the number of instances in apattern. If this was odd, I wanted the offset distance of the partto be patterned to be different than if it was even.

If there is a more straight forward way of doing this, then let meknow!

I set the number of instances like so...

"Num" = 4

Then to find if that's odd or even, I used...
"OddOrEven" = "Num" MOD 2

Which gives 1 if its odd and 0 when even since MOD works out theremainder when the first variable is divided by the second. And itsnot case sensitive.

Then, I used...
"Offset" = IIF ( "OddOrEven" LIKE 0 , "EvenValue" , "OddValue" )

Where "EvenValue" and "OddValue" are the value I want the dimensionto be when the "Num" is even or odd.

Finally, I linked the dimension with the variable "Offset" totransfer it back the model.

I was trying to set "OddOrEven" = 0 for ages inside the IIFstatement, but Solidworks wouldn't let me, then I found out I canuse LIKE, which means the same thing to SW and it was happy! SinceI don't know any VB this was new to me!!

I hope someone else finds this useful!
SolidworksGeneral