iLogic Code for Creating Min/Max Design Limits in Autodesk Inventor – 2

iLogic Code Writing Tutorial Two - Image-01I left off in the last iLogic code post with the code that limits the Shaker Table’s apron  to a minimum of two inches. Today’s post will cover the apron’s maximum width code as well as the min/max for the thickness.

But first, I promised to show how to make the model semi-transparent. It is not at all necessary to do so, but I like to use the technique when adding and testing iLogic code so that I can get an x-ray view as to what is going on in my model. I have posted the How-To under the title iLogic Code Writing and Testing in a Semi-Transparent Model

Now, back to writing iLogic code. The maximum apron width code is shown below. The formula I came up with makes sure you can make the apron as wide as you want without blowing things up in the model. The parameters used within the formula (mostly the Taper_Min_Height and the Taper_Reveal) can be tweaked as well to create whatever look or other outcome you may desire.

 

‘Apron Width Max Width
‘If apron width is set to be equal or greater than the formula below, then reset it to the same formula…

If Apron_Width > Overall_Height - (Top_Thickness +Taper_Reveal + Taper_Min_Height) Then
Apron_Width = Overall_Height - (Top_Thickness+ Taper_Reveal + Taper_Min_Height)
MessageBox.Show(The Apron Width you have entered has exceeded the maximum width. It has been resized to the current maximum of “ & Apron_Width &inches “, “Width too Wide”)
End If

 

I will likely create a drop-down list of standard widths later in this series of tutorials –with the ability to override same and add any width within the min/max we are now setting up. But for now, we’ll stick to the script. The code below sets the minimum thickness of the aprons. I did not use a ‘hard’ number such a ½” just in case the leg were to be sized really small. I have no idea why one would do so, but we are all about setting reasonable limits, not limiting future design possibilities.

 

 

I will likely create a drop-dow n list of standard widths later in this series of tutorials –with the ability to override and add any width within the min/max we are now setting up.

 

‘Apron Thickness Min
‘If apron width is set to be equal or greater than the formula below, then reset it to the same formula…

If Apron_Thickness < Leg_Width / 4 Then
Apron_Thickness = Leg_Width / 2
MessageBox.Show(“The Apron Thickness you have entered is less than the minimum thickness. It has been resized to ” & Apron_Thickness & ” inches”, “Too Thin”)
End If

 

The last chunk of iLogic code will control the apron’s maximum thickness. Again, it uses a formula instead of a hard number to allow for more design possibilities down the road.

 

‘Apron Thickness Max
‘If apron width is set to be equal or greater than the formula below, then reset it to the same formula…

If Apron_Thickness > Leg_Width / 4  *  3 Then
Apron_Thickness = Leg_Width  / 4  *  3
MessageBox.Show(“The Apron Thickness you have entered is more than the maximum thickness. It has been resized to “& Apron_Thickness & ” inches”, “Too Thick”)
End If

 

All of the above may be tweaked later on as I have only a vague plan as to the direction of this tutorial –but that will create an opportunity to demonstrate how to modify existing models with iLogic code.  

 

Now that the apron has its min/max code in place, the last thing to do is test it. Open the Form 1  form and play around with the numbers, you should not be able to adjust it beyond the design limits you just created. You should get an error message explaining any entries that are beyond the min/max set in the iLogic code, then the model will resize to the limit. You can also comment out the message boxes and have the code just do its work –which is just fine in a one-man shop setup.

 

iLogic Code Writing Tutorial Two - Image-02 - Testing code written in Autodesk Inventor's iLogic code

Just by setting the apron’s width to 99” (which snapped back to the min of 16” at this overall height), I notice that the table starts to look a lot like an old-fashioned dough table, and it wouldn’t’t be very hard to create that option –or to add drawers to create a dresser. One model can be configured to represent numerous items –maybe we will go down that road later if there is enough interest.

 

iLogic Code Writing Tutorial Two - Image-03

 

Next, I probably should write the iLogic code that controls the overall min/max for the entire piece…….. where things go from there is anyone’s guess. Have a great new year!

 



Subsribe to Post Notifications


 





4 thoughts on “iLogic Code for Creating Min/Max Design Limits in Autodesk Inventor – 2

  1. hello,
    Thanks for all the works you put up, I got very much but then I got one error and hope that you could help.

    I put this code:
    Apron_Width > Overall_Height – (Top_Thickness+ Taper_Reveal + Taper_Min_Height)

    Then it put out error below:
    Rule Compile Errors in Apron Min/Max Rule, in Master Table Desk.ipt

    Error on Line 4 : Property access must assign to the property or use its value.
    Error on Line 4 : Expression expected.
    Error on Line 4 : Method arguments must be enclosed in parentheses.

    Thanks

    • Hello again Luong,

      I’m not sure how it happened, but the error you are getting should only happen if the line above it is “commented out”. Is the third line of code gray like the first two? If so, then the error makes sense as the line four code is not valid without the line above it. Paste this into the editor and see what happens…

      ‘Apron Width Max Width
      ‘If apron width is set to be equal or greater than the formula below, then reset it to the same formula…
      If Apron_Width> Overall_Height – (Top_Thickness +Taper_Reveal + Taper_Min_Height) Then
      Apron_Width >Overall_Height – (Top_Thickness+ Taper_Reveal + Taper_Min_Height)
      MessageBox.Show(“The Apron Width you have entered has exceeded the maximum width. It has been resized to the current maximum of “ & Apron_Width & ” inches “, “Width too Wide”)
      End If

      Mark

  2. Come back to site – thought you had stopped posting! Fantastic tutorial for the shaker table. Couple of errors that need correcting to help Loung Tran out. The second instances of < ought to be = in the Max Width and Thickness Max code.

    • Hello William,

      Thank you and glad to have you back!

      You are correct, the second lines in most of these mix/max code snippets should have = not &gt; or &lt; –including these. They have been corrected. Sorry Luong! Thanks for the heads-up William!

      The next post in this series will be later today where I’ll be creating the solids from the layout part. Hope you stop back to see it.

      Mark

Leave a Reply