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
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
If Hanger_Bolt_Length >= 4 Then
Hole = .3125
Bracket_Offset = ((Hanger_Bolt_Length / 5) * 3)- Nut_Offset
If Bracket_Offset < Apron_Thickness Then
Bracket_Offset = Apron_Thickness
‘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
iLogicVb.RunRule(“Hanger Bolt:1″, “Hanger Bolt”)
iLogicVb.RunRule(“Designing a Shaker Table with Autodesk Inventor:1″, “Min/Max”)
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.
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