In this Inventor iLogic tutorial we will insert a small subassembly (the Hanger Bolt) into the main assembly (the Shaker Table), create a bidirectional information flow between the two with iLogic code, and create an interface that will run the assembly as well as report model information.
This Inventor iLogic tutorial builds on the Shaker Table series of tutorials and picks up after the end of the previous post.
In this Inventor iLogic tutorial the first thing we will be doing is making a few changes in the Designing a Shaker Table with Autodesk Inventor.ipt. The first is to how the dimension that has the Bracket_Offset parameter driving it was placed. I decided to use the Bracket_Offset dimension to drive the model via a dimension, but it will need to be placed a bit different. In the Shaker Table part, double click on the Corner Bracket Sketch to make it active. Make sure you have your dimensions showing expressions (right click > Dimension Properties > Document Settings > Modeling Dimension Display > Show Expression), highlight the one that has Bracket_Offset as an equation, and hit delete. We will place it again, but do so in a way that cannot turn inside-out when driven to zero. To begin with, draw what I refer to as an ‘outrigger’ line starting at the inside corner of the leg and moving towards the outer corner. When you see the Parallel glyph to the centerline of the bracket, click to end the line…
With the outrigger in place, we will now put the Bracket_Offset dimension back in. This time we will place the dimension to the FAR side (towards the inside of the table) of the bracket, and to the free end of the outrigger we just made, and make the formula Bracket_Offset + 1 in…
Now hit the checkmark on the Edit Dimension dialog to finalize things……and your bracket sketch will pull down into the leg. Fix this by going to your Parameter Editor and changing the Equation for the Bracket_Offset to 2” —later on, this parameter will be controlled at the assembly level, but 2” will do nicely until that happens.
Now for the length (depth) of the hanger bolt hole. You may remember back in the last installment when I drilled the hanger bolt hole all the way through the leg. I said that we would be using iLogic to control the Hanger_Bolt_Length parameter. That was a misstatement (as William pointed out –it’s a reference parameter and cannot be controlled). What I should have said is that the Hanger_Bolt_Length would be used in the formula (as a max length indicator) for the depth of the hole. We still need to change the hole depth to the Hanger_Bolt_Depth parameter we created in the last installment. To do so, just double click on the HangerBoltHole feature, and use the parameter drop-down for the Length to make the switch…
While mulling things over about how to continue (the modeling is not done in advance), I realized I could simplify the parameters for the four diameters the holes which were also created in the last installment down to two, and use a variable at the top level assembly to do the rest. You will see what I mean later, but for now we’ll do the changes. We used the Lg_Hangerbolt and Lg_Hangerbolt_Clearance to create the hole, and we will keep them. Just rename them to lose the Lg_ prefix to get Hangerbolt and Hangerbolt_Clearance. Delete the Sm_ versions altogether…
I’m pretty sure that’s it for the changes –at least for now. Which brings us to the placement of the hanger bolt assemblies. Click the Place tool on the Component Panel, and choose the Hanger Bolt.iam, place one near each corner of the table…

To constrain the bolt assemblies, start the Constrain tool on the Position Panel, and choose Insert as the Type. Select the inner edge of the washer as the first selection…
…then the rim of the hole as the second selection…
Click apply, and move on to constrain the others. When done with the last bolt’s placement, click OK to finish up the command. Save the model. We will now add the parameters at the assembly level. Open the Parameter Editor and add the following parameters…
We will be accessing the layout part Designing a Shaker Table with Autodesk Inventor:1 from the rules we are about to write (or copy and paste) so right click it and unsuppress it in the assembly. Now on to the rules. Right click in the iLogic Browser, and choose the only thing in the context menu, Add Rule. Name the rule Main. Next, you should probably just copy and paste the code below between the star lines into the iLogic Rule Editor.
Update: The code below is causing problems –likely due to unicode characters being added by Word or possibly something WordPress adds. At any rate, do not cut and paste the code below, a plain text version can be found here: ShakerTableCode-01-25-12.txt
******************************************************************
Nut_Offset = Parameter(“Hanger Bolt:1″, “Nut_Offset”)
Overall_Size= Overall_Width * Overall_Length
Largest_Overall_Size = 4559 ‘The value of the Overall_Size parameter when driven to the Max size
Size_Unit = Largest_Overall_Size / 8 ‘Number of hanger bolts
If Overall_Size > 4559 Then
Overall_Size = 4559
End If
Hole = .25
Clearance = .0625
If Overall_Size Size_Unit Then
Hanger_Bolt_Length = 1.5
Else If Overall_Size > Size_Unit And Overall_Size <= Size_Unit * 2 Then
Hanger_Bolt_Length = 2
Else If Overall_Size > Size_Unit * 2 And Overall_Size <= Size_Unit * 3 Then
Hanger_Bolt_Length = 2.5
Else If Overall_Size > Size_Unit * 3 And Overall_Size <= Size_Unit * 4 Then
Hanger_Bolt_Length = 3
Else If Overall_Size > Size_Unit * 4 And Overall_Size <= Size_Unit * 5 Then
Hanger_Bolt_Length = 3.5
Else If Overall_Size > Size_Unit * 5 And Overall_Size <= Size_Unit * 6 Then
Hanger_Bolt_Length = 4
Else If Overall_Size > Size_Unit * 6 And Overall_Size <= Size_Unit * 7 Then
Hanger_Bolt_Length = 4.5
Else If Overall_Size > Size_Unit *7 And Overall_Size <= Size_Unit * 8 Then
Hanger_Bolt_Length = 5
End If
If Hanger_Bolt_Length >= 4 Then
Hole = .3125
End If
Bracket_Offset = ((Hanger_Bolt_Length / 5) * 3)- Nut_Offset
If Bracket_Offset < Apron_Thickness Then
Bracket_Offset = Apron_Thickness
End If
‘Send to parts
Parameter(“Hanger Bolt:1″, “Length”) = Hanger_Bolt_Length
Parameter(“Designing a Shaker Table with Autodesk Inventor:1″, “Hangerbolt”) = Hole – Clearance
Parameter(“Designing a Shaker Table with Autodesk Inventor:1″, “Hangerbolt_Clearance”) = Hole + Clearance
Parameter(“Designing a Shaker Table with Autodesk Inventor:1″, “Hanger_Bolt_Depth”) = Hanger_Bolt_Length
Parameter(“Designing a Shaker Table with Autodesk Inventor:1″, “Apron_Thickness”) = Apron_Thickness
Parameter(“Designing a Shaker Table with Autodesk Inventor:1″, “Bracket_Offset”) = Bracket_Offset
Parameter(“Designing a Shaker Table with Autodesk Inventor:1″, “Overall_Width”) = Overall_Width
Parameter(“Designing a Shaker Table with Autodesk Inventor:1″, “Overall_Length”) = Overall_Length
Parameter(“Designing a Shaker Table with Autodesk Inventor:1″, “Overall_Height”) = Overall_Height
‘Update parts
iLogicVb.RunRule(“Hanger Bolt:1″, “Hanger Bolt”)
iLogicVb.RunRule(“Designing a Shaker Table with Autodesk Inventor:1″, “Min/Max”)
InventorVb.DocumentUpdate()
Adj_Overall_Width = Parameter(“Designing a Shaker Table with Autodesk Inventor:1″, “Overall_Width”)
Adj_Overall_Length = Parameter(“Designing a Shaker Table with Autodesk Inventor:1″, “Overall_Length”)
Adj_Overall_Height = Parameter(“Designing a Shaker Table with Autodesk Inventor:1″, “Overall_Height”)
Also, if the hole sizes in your model are not changing without manualy updating the model, you will need to add the following two snippets AFTER the rest of the code in the Min/Max rule in the layout part. It will force an update so that the manual local update is not needed. To insert it, go to the rule stated above, put your insert marker below the code there, expand the Run Other category in the System Tab of the Snippets column (left of editor window), then double click on the first one, hit enter for a carriage return, then double click on the other. Hit OK and you should be good-to-go.
RuleParametersOutput()
InventorVb.DocumentUpdate()
******************************************************************
Once you have done that, close the editor to save and run the rule. If you get an error, it is likely you misspelled one of the parameters we just added or failed to unsuppress the layout part. If you do get a failure, comment out (Highlight the code > right click > Comment Selection) the offending code and try to find the problem.
You should be good-to-go to make a form to control things. Switch to the Forms Tab on the iLogic Browser, then right click and choose Add Form. In the Form Editor that appears, click the Form 1 text at the top center and rename the form Configure Table. With form still selected (the Configure Table line), go down to the Behavior list, and change the Predefined Buttons to OK Cancel Apply. Now drag the parameters and toolbox items seen in the image below over into the form field…

Change the Label 1 text to “Enter desired dimensions:” and the Label 2 to: “Actual dimensions after overrides:”. Now select the bottom three parameters one at a time and switch from ReadOnly False to ReadOnly True in the Properties pane. Click OK to accept the form, and save your model. Now test the model. Enter some dimensions and click OK.

The model should update smoothly. The hanger bolt clearance hole through the brackets should be 1/16” larger than the bolt, and the pilot hole in the leg should be 1/16” smaller than the bolt. The bolt should have changed size automatically based on the overall size of the table. Any numbers entered beyond the range of the min/max are corrected at the part level, and the adjusted size is reported in the lower fields.
That about wraps up this Inventor iLogic tutorial. I’ll explain the code in the next installment, then most likely I’ll prep the table for creating a meaningful cutlist in the final drawings. I will likely wrap this up within the next few installments, then come back to it after some time to demonstrate something that needs demonstrating. I found that the smaller sized hanger bolts can go away –or the table could be configured to get much more structurally petite at the smaller sizes to make them worthwhile.
Until I post with the explanation of the code, go through it and see if you can figure it out. Later.
Subsribe to Post Notifications










Shazam. This is one of those parts of the puzzle I was looking for Mark. Thank You. The next question you already mentioned….explaining what the heck you just typed in for the iLogic code. I understood most of it and can kind of piece it together. I have not found much "out there" that explains what all the functions do with iLogic in the form of books or sites. Thanks again Mark, great stuff for rounding things out. It's making much more sense now.
Hi Kent,
Nice to see someone else uses the word Shazam. A world-class word if there ever was one
The explaining part will take up a whole post, and even at that, may leave some people fuzzy headed. I guess it all depends on how much code of any type a person has written in the past. Some people will just not ‘get’ it ever.
A hint though is that the brown text are variables that can receive values from damn near anywhere in the model (even a typed in static value like Overall_Size = 4559). These are generally found in the beginning.
Variables and parameters are generally used in equations to figure something out in the center section of the code.
Towards the end, the values that were figured out earlier are sent to the parts, and any code within the parts is forced to run.
In this instance, after the code does its deed, I return values for use in the iLogic Form.
Hope this helps with your code exploration until I get to the next post.
Mark
Having trouble with the copy and paste part. I started re-working the code and I don't know if it's just a browser thing, but I am now manually typing in exactly what you had and it works now, at least the very beginning of the code. I have a huge run compile error with copy/paste.
FYI, from the start of your code "If Overall_Size Size_Unit Then …." looks like there is a ">" missing. I am assuming it is ">" I'm working through the rest of it now and see what I come up with. I'm getting quite a few
Error on Line 30 : End of statement expected.
Error on Line 32 : End of statement expected.
Error on Line 34 : End of statement expected.
But I will work through it and comment back when I get it handled.
Hi Kent,
The code itself is fine, but I got the same errors. Apparently either Word or WordPress is adding Unicode or other characters to the text that iLogic is choking on. I put the code up as a text file, and it should run fine with it:
http://cdn.opendesignproject.org/uploads/2012…
If not, there are other problems and they would have to be dissected from there.
Mark
Hi Mark, Got a lot of errors. I'll try and work through them. Most just require renaming (I've called my part "Shaker Table" for example). However, aren't there 8 instances of relational operators missing in the first large block of code (Overall_Size Size_Unit etc). Are they all "<"? Hope I get it right as can't wait to see it fully operable – Great Stuff.
Hi William,
Hmmmmm. There appears to be a problem here. Look at the text version of the code, and you will see that the code reads “Overall_Size <= Size_Unit” in each of those lines in the large code block. It doesn’t make a lick of sense without it, and will not work! Great catch!
I’m going to do some testing and see if WordPress, Word, or Expression Web is stripping out parts of the code. All three like to “fix” things for you, and could be the culprit. In fact, WordPress was so bad until the latest major upgrade that it was barely useable for anything beyond text.
I’ll post whatever I find, until then there is a text version linked to in the article itself just above the code, and one in a comment above as well. Thanks again!
Mark
To all,
As I was writing the code explanation for the next post, I realized I forgot a small chunk of code that I inserted in the Min/Max code of the Layout Part. It is not needed to run the code here, but what it does is forces the part to update itself if it is not doing so. Mine needed it, but I now comment the two lines out and the model is still running fine.!
Whatever…… I posted the code up above with the rest of the code as well as an explanation on how to use the snippets window to insert it. If your model is updating fine, forget it.
Mark
Hey Mark (Sensei!),
What a great lesson! I had the same errors as the others did, but I just assumed that you were attempting to inspire critical thinking and problem solving skills, and worked my way through it last night. I actually learned a lot more this way than if the code had copied correctly the first time!
The fact that I was able to do this is testament to the quality of the tutorials here, as this is my first exposure to utilizing code.
Thanks to you Mark!
Jerry
Hi Jerry,
Congratulations, and thanks for the complements! I’m glad you could turn potential frustration into a learning experience. There seems to be a lot more giving up than forging ahead these days. It also shows you will likely ‘get’ code in general. Some people just don’t. Ever.
As for the problems posting code, I found a plugin that will allow real code to be pasted into the articles, along with the correct syntax highlighting. The problem is that it is unlikely that the syntax highlighter will recognize iLogic code (yet). iLogic is based on Visual Basic, but I’m pretty sure there are differences, and I may need to tweak the plugin’s code. The other problem is that the plugin is no longer supported by the original author –but it is being held in life support by a couple of guys.
Wish me luck.
Mark
"I actually learned a lot more this way than if the code had copied correctly the first time!"
I also agree with this. It forced me to take a look at the code and try to figure it out myself. I got most of it but was stuck on the iLogicvbRunRule part. The wording was identical, but something was just not connecting. It is all set now. I have a short squat coffee table looking model. I can't wait to find out what I just did though lol.
If you haven’t figured it out yet, the iLogicvb.RunRule tells other parts or assembles to run a specific rule contained within said part or assembly……………..
Run Rule – Where Rule Lives – Rule’s Name =
iLogicVb.RunRule("Hanger Bolt:1", "Hanger Bolt")
Mark
Thanks Mark for the text file of the code. All working OK now (after renaming parameters etc). Great stuff. Learnt a great deal. Nothing else on the web about iLogic like this. Notice that the code will not run if the layout part is suppressed and that parameters like apron width, apron thickness etc can still be updated directly from the the min/max rule in the ipt file. "to demonstrate something that needs demonstrating" – how about a clue as to what you referring to – gives us an opportunity to try and work it out for ourselves before you enlighten us.
Hi William,
The "to demonstrate something that needs demonstrating" referred to bringing code up from the part level where it was used for development purposes, to the top level assembly where it is better suited in many cases. Also, I may convert the top to multiple boards for a glue-up schedule. Most likely I’ll add on to this tutorial here and there whether it makes sense or not to do so in the wild. Somebody will be able to extract something out of anything, so it’s best to just keep shoveling it out there.
Not sure if anyone noticed, but there will now be lists for all series tutorials. The Shaker Table is there, and future series will be there as well.
Back to work. The code summery will be out there tomorrow.
Mark
Thanks Mark for the text file of the code. All working OK now (after renaming parameters etc). Great stuff. Learn a great deal.
You are quite welcome Mr. Pins!