I'm attempting to build a sheet metal panel in a rectangular pattern both vertically and horizontally. All holes in pattern are to be the same size. The other criteria that the pattern MUST follow is that the hole pattern itself, whether square or rectangular MUST BE CENTERED on the sheet metal face.
Using an iLogic Form, I am able to drive the dimensions for the sheet itself, the hole diameter, the number of rows and the number of columns. I am also able to input offsets both/either vertically or horizontally. When either or both the Number of Rows or the Number of Columns is odd, one (1) hole centrally placed on the sheet metal face allows for my design intent to work properly. When the hole pattern requires either an even number of Rows or Columns, an offset is needed. Through some experimentation, I've been able to figure out the amount of displacement required to center this type of hole pattern.
What I'm in need of is code to test that either the Number_of_Rows value is even or odd and Number_of_Columns is either even or odd. After testing for even or odd iLogic needs to update the hole location both horizontally and/or vertically as needed. Instructions on how to update variable with iLogic are also needed. I'm a newbie!
Code would be similar to the following:
Test Number_of_Rows for "oddness"
If Number of Rows is odd then
oHOFFSET = 0
ELSE oHOFFSET = 3
Parameter ("Horizontal_Offset") = 3
END IF
Any tips, suggestions or errata on testing a value for being even or odd would be greatly appreciated!
Solved! Go to Solution.
The modulo operator is what you're looking for (Mod in iLogic or % pretty much everywhere else). It returns the remainder after a division.
If NumberOfRows Mod 2 = 0 Then //Do even things Else //Do odd things End If
bd727 wrote:
The modulo operator is what you're looking for (Mod in iLogic or % pretty much everywhere else). It returns the remainder after a division.
If NumberOfRows Mod 2 = 0 Then //Do even things Else //Do odd things End IfSince I wish to test Odd first, I should use the following code:
If Number_of_Rows Mod 2 = 1 Then
// Do odd things
ELSE
// Do even things
End If
Would that be correct?
Thank you for your assistance. It is greatly appreciated!
Can't find what you're looking for? Ask the community or share your knowledge.