Inventor iLogic Assembly Automation Tutorial Decoded

Inventor iLogic Code Tutorial image 01 - Image of iLogic CodeThis post is a follow-up to the Assembly Automation Tutorial for Inventor iLogic post where we added the fifty-some odd lines of iLogic code to our Inventor Assembly. Today’s post will attempt to explain that code.

This post was supposed to be published yesterday, but I spent most of the day screwing around with a plugin that will eventually allow me to post Inventor iLogic code with the proper syntax highlighting that can be copy & pasted right from the webpage into your iLogic Code Editor without intermediate programs adding special characters that screw up the code. I’ll be posting a bit more on that in the next post. Until that is up-and-running, I’ll use images…   

 

Inventor iLogic Code Tutorial image 02 - This is the image of the first chunk of iLogic code used in our sample

The first two lines of code (above) are creating variables. The Nut_Offset variable gets its value by  reading the Nut_Offset parameter in the Hanger Bolt:1 part. The second variable, Overall_Size is reading two local parameters (Blue) and multiplying them against each other to get its value.

 

Inventor iLogic Code Tutorial image 03 - This is a typical block of Autodesk iLogic code

The next snippet of code (above) creates a new variable called Largest_Overall_Size, and has a static value that I created by dividing the largest possible width * the largest possible length. The line after that creates a variable based on a division of the Largest_Overall_Size. There are 8 sizes of hanger bolts, so the overall size was divided by 8.

The If – Then statement at the end of the above chunk catches an error where the user enters a number larger than the max size and returns the size to the max. This is there because the code that corrects oversized parts (the min/max code in the table part) has not yet run at this point, so that info cannot be pulled in at this point, and a static value was used. In the real world, I would likely have moved the code from the part to the top level, but decided not to for the tutorial. If anyone wants to know how to do it, let me know and I may do a post on it.

 

 Inventor iLogic Code Tutorial image 04 - This image shows some variables in the iLogic Code Editor

The Hole variable above sets the size of the holes in the bracket and leg at ¼”. A small If – Then statement below the code block below changes the value to 5/16” if the hanger bolt is 4” or longer. The Clearance variable is where a shop standard hole clearance is added to the formula. Both values are sent to the parts in code below. This could be built upon to have the bolt hole change size depending on the type of wood to eliminate splitting.

 

Inventor iLogic Code Tutorial image 05 - The block of iLogic code that determines the size of the hanger bolts.

The above block of code simply divides the model into eight units, and assigns one of the eight possible hanger bolt assemblies to the model based on its overall size. In the real world, you would likely have only a couple sizes of hanger bolts –or maybe cheap stapled in plastic corners for that matter. This exercise is not meant to provide you with a RTM solution, just the bits to cobble together your own.  

 

 Inventor iLogic Code Tutorial image 06 - This snippet of iLogic code changes the diameter of the bolt based on length

The above code is the little snippet mentioned above that uses the final Hanger_Bolt_Length determined by the big block of code above, and if it is 4” or longer, changes the Hole variable to 5/16”.

 

Inventor iLogic Code Tutorial image 07 - This is the Autodesk Inventor code that automatically sets the depth

The first line of the code above makes sure the hanger bolt (in all cases were the bolt is long enough) is only into the leg the depth of its screw portion. To get a better idea how that is accomplished you need to refresh your memory as to the formula we used for the thread lengths on the hanger bolt.

 

 Inventor iLogic Code Tutorial image 08 - Using iLogic code to send vital information to subassemnlies and parts

All of the above lines of code send info to a parameter in a part. Some of the values are what we will enter into the form, and some are the final value of variables created earlier in the code.

 

 Inventor iLogic Code Tutorial image 09 - This iLogic code updates the subassemblies and parts

With new values sent to the parts, the snippet of iLogic code above forces the parts to run their own rules (which in some cases changes the input).

 

 Inventor iLogic Code Tutorial image 10 - The above iLogic code returns values from parts and subassemblies to the master model

The above code returns the corrected (if necessary) numbers outputted by the Min/Max rule to the actual dimensions section of the form so that the person entering the two can compare the two. If we get rid of the Adj_ prefix on all three, we can simply overwrite the user’s input with the corrected values, and get rid of the adjusted section of the form…

 

Inventor iLogic Code Tutorial image 11 - This is adjusted iLogic code

But for this exercise, we will leave the adjusting version intact.

 

Note: Once the code in the layout part runs, I initially was not seeing an update of the hole diameter in the assembly parts without a local update. So I added the following snippets to Min/Max Rule (very end) in the Layout Part. They are from the Document list in the System Snippets:

 

Inventor iLogic Code Tutorial image 12 - These are iLogic automatic update rules

The first one updates the document (the Layout Part in this case) immediately after running the rule, and the second outputs the parameters to the model –where I am grabbing them at the assembly level to display true driven dimensions. The model should do both of these automatically, and indeed, mine is again doing so. I have since commented the snippets out and everything is working just peachy…..humpf. Use it if you need it.

 

And that’s it for today’s Inventor iLogic Tutorial. In the next installment I’ll add the pixy dust that will allow automatic parts lists later. It would be a good time to modify the top so that it not only gives the number of boards needed and their respective sizes, but changes that amount and size information based on the overall size of the table. But I’ll likely press on towards the drawings and go back later. It’s a piece of cake to modify a model like that, and indeed it is part of the design process and should be a part of the learning experience. Only the most simplistic of designs can be ‘seen’ from beginning to end. Usually there is a good idea as to the path that needs to be taken, and adjustments are made along the way to match the realities encountered.

Later.

 



Subsribe to Post Notifications


 





2 thoughts on “Inventor iLogic Assembly Automation Tutorial Decoded

    • :) Coming either later tonight, or tomorrow. Currently fixing hundreds of bad links due to website restructure, working on Q & A section, and trying to get code highlighting plugin working correctly. On top of that, this AM, waiting for web hosting service to deal with DOS attack on their servers.

      Coming soon though.

      Mark

Leave a Reply