Inventor Customization

Reply
Distinguished Contributor
Posts: 145
Registered: ‎06-20-2006
Message 1 of 5 (695 Views)
Accepted Solution

How to test for EVEN or ODD variable values with iLogic 2012?

695 Views, 4 Replies
07-03-2011 02:02 PM

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!  :smileysad:

 

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!

Jim Strenk

Inventor 2012 Certified Associate
AutoCAD 2012 Certified Associate

Product Design Suite Ultimate 2012, 2013 & 2014

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!
Contributor
BrentDouglas
Posts: 18
Registered: ‎04-03-2011
Message 2 of 5 (690 Views)

Re: How to test for EVEN or ODD variable values with iLogic 2012?

07-03-2011 10:34 PM in reply to: JimStrenk

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
Distinguished Contributor
Posts: 145
Registered: ‎06-20-2006
Message 3 of 5 (684 Views)

Re: How to test for EVEN or ODD variable values with iLogic 2012?

07-03-2011 11:00 PM in reply to: BrentDouglas

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 If

Since 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!


 

Jim Strenk

Inventor 2012 Certified Associate
AutoCAD 2012 Certified Associate

Product Design Suite Ultimate 2012, 2013 & 2014

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!
Contributor
BrentDouglas
Posts: 18
Registered: ‎04-03-2011
Message 4 of 5 (680 Views)

Re: How to test for EVEN or ODD variable values with iLogic 2012?

07-03-2011 11:21 PM in reply to: JimStrenk
That's correct. Glad I could help.
Distinguished Contributor
Posts: 145
Registered: ‎06-20-2006
Message 5 of 5 (675 Views)

Re: How to test for EVEN or ODD variable values with iLogic 2012?

07-04-2011 01:25 AM in reply to: BrentDouglas

Thanks a million!  I've just finished cigarette pack #3 trying to figure this stuff out.

Jim Strenk

Inventor 2012 Certified Associate
AutoCAD 2012 Certified Associate

Product Design Suite Ultimate 2012, 2013 & 2014

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube