This 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…

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.

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.

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.

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.

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”.

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.

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.

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).

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…

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

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




Must…. Have…. Pixy Dust!!!
Coming soon though.
Mark