Inventor iLogic – Rounding Decimals to Nearest Fraction

Inventor iLogic Rounding Tutorial Image 01 - An automatic cutlist for woodworking generated in Autodesk InventorThis post is an adjunct the Shaker Table series, and describes how to grab a decimal number from an Inventor iLogic parameter, round that number to the nearest specified fraction, then pass that new number to a new parameter that will make its way to a Cutlist.

What is happening here is that the model is reporting a length from a driven dimension  which can have quite a few numbers after the decimal point. The output we need is the closest fractional equivalent, so we will apply some math to round the driven dimension’s output to a fractional number. In this case, we will round to the nearest 32nd which would be a shop standard tolerance. The image below shows the driven dimension in question. It is attached to a line that describes the inner face of a corner bracket on a table design. The length of the line is entirely dependent on the overall size of the model as defined by the person fiddling with the inputs…

  Continue reading






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

 
 
 
 
 
 
 
 
 
 

In this post we will add the rest of the current parameters to the iLogic’s Form Editor so that we may blast through the rest of the min/max iLogic code. I’ll make this one as short as possible as I think you may have it down-pat by now. If not, use the comment box at the end of the post to get clarification.

 To begin this iLogic code writting session, we will go to the Forms Tab on the iLogic Browser, and right click on the Form 1 form we created in the last installment. Choose Edit, which will bring up the iLogic Form Editor. First thing to do here is drag all of the rest of the parameters over to the form. When that is done, grab a Tab Group tool from the Toolbox in the lower left, and place it at the top of the list of parameters you just dragged over. Now add another one somewhere in the middle of the pack. Now click on the Label 1 text and change it to Shaker Table. Now change the names of the tabs you just created to Main and Secondary. Now its just a matter of dragging the parameters and dropping them on top of whichever tab they will belong on…

 

iLogic Code Writing Tutorial Three - Image-01 - Add parameters to the iLogic Form Editor

  Continue reading






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

Continue reading






iLogic Code Writing and Testing in a Semi-Transparent Model

iLogic Code Writing Tutorial - Image-01When writing iLogic code in Autodesk Inventor, you need to test the code constantly to assure that it is behaving as expected in your model. Some of what is happening would normally be hidden from view. The answer to that problem is to have a semi-transparent model while testing. Here’s how to do it….

 

For this tutorial on iLogic code I have used the table from the Shaker Table Tutorial for this how-to, but any part with multiple solid bodies will do.

 

Continue reading






iLogic Rule for Inventor Text Manipulation

 
 
 
 
 
 
 
 
 
 
 
 
 
 

This iLogic Rule will save a great deal of time in the creation of changeable text features such as the embossed head markings on the FastenMaster BIM objects on this site.

On with the iLogic Rule. If you open the Inventor iLogic version of the OlyLog part, you can see that in the original file I created nine separate sketches, each with their own emboss feature —then manipulated the suppression of these features to create the head markings required.

It was quite easy to write the original code for these parts, but suppression/unsupression of features is probably the thing that causes Inventor to bog down the most. At any rate, all the extra features creates a lot of bloat in the code as can be seen in the codeblocks below.

This is the original code as you will find it over in the BIM section. There is one iLogic Rule called Resolution (as in high or low resolution for the BIM objects) note that there is a Boolean (True/False) statement for each Head Mark feature available:

If Part_Number = “LOG212″ And Part_Quality = “High” Then
Part_Length = 2.5
Thread_Length = 1.25
Feature.IsActive(“Thread Normal”) = False
Feature.IsActive(“Head Fillets”) = True
Feature.IsActive(“Head Mark 2.5″) = True
Feature.IsActive(“Head Mark 4.0″) = False
Feature.IsActive(“Head Mark 6.0″) = False
Feature.IsActive(“Head Mark 8.0″) = False
Feature.IsActive(“Head Mark 9.0″) = False
Feature.IsActive(“Head Mark 10.0″) = False
Feature.IsActive(“Head Mark 12.0″) = False
Feature.IsActive(Head Mark 14.0″) = False
Feature.IsActive(“Head Mark 16.0″) = False
Feature.IsActive(Point threads”) = True
Feature.IsActive(“Shank Threads”) = True
Feature.IsActive(“Shank Chamfer”) = True

And this is the new code. Notice that all of the Feature.IsActive statements related to Head Marks are gone. This is now handled by a new string parameter called SketchText.

If Part_Number = “LOG212″ And Part_Quality = “High” Then
Parameter(“Part_Length”) = 2.5
Parameter(“Thread_Length”) = 1.25
Parameter(“Text_Width”) = .132
Feature.IsActive(“Thread Normal”) = False
Feature.IsActive(“Head Fillets”) = True
Feature.IsActive(“Point threads”) = True
Feature.IsActive(“Shank Threads”) = True
Feature.IsActive(“Shank Chamfer”) = True

It would be easier to use a string parameter directly to control the text, but in this case it was not possible. The choices needed to be the part number –which is not the same as the text that needs to appear on the head of the fastener. What I did was map the values of the new SketchText string parameter to the existing Part_Number parameter values in a new rule called “Equality” which looks like this…

If Part_Number = “LOG212″ Then
SketchText = “2.5″

…note that the value of the SketchText parameter is contained within quotation marks. If this were not so, the value returned would be a number, and every number besides the 2.5 value would truncate to the whole number –which is not how the markings need to appear. The quotation marks will force the return of a string (text) value.

There is also another rule called TextChanger that does the majority of the work in the background. In that rule, as can be seen in the code below, you need to specify the string parameter, which is named SketchText in this instance. This is the multi-value parameter that holds the values that will appear in the text feature. The “HeadMarks” value is the name of the actual sketch in the browser, and would need to match the name of your particular sketch (when you create your own).

AddReference “System.Web”
Imports System.Web

Sub Main()
     doc = ThisDoc.Document
     Dim strings as New Generic.List(Of String)
     strings.Add(SketchText) ‘string parameter holding text I want to push to the sketch
     ‘strings.Add( EmbossTextLine2)

     SetSketchText(“HeadMarks”, strings)

End Sub

The video and text tutorial below describes how to create a quick version yourself. You may want to uncomment the gray text and try multiple lines of text…looks pretty easy.

Now for a very quick tutorial to show how this all works generically. Start a new part, and create a rectangle on the XY plane 1″ tall by 2½” wide and extrude to ¼” thick. On the XY face of this, create a new sketch, and activate the text tool. Change the size of the text to .240 and type Text into the text box. Center the text by Center and Middle  justifying the text, then constraining the text bounding box to the perimeter of the face you are working on, then exit the sketch. Rename the sketch Text (if you watch the video, you will see that you will get an error if you forget this part).

 

 

 

 

Open the iLogic Parameter Editor and create a rule called SketchText, and make it a string (text) parameter, then make it multi-value. In the Value List Editor, add “Number One”, “Number Two, Number Three, and “Number Four” hitting enter after each one.

Now download this snippet of code (text format), open the file and copy the rule to the clipboard. Start a new iLogic rule named Text Changer, and paste the text you just copied into the Rule Editor.

You should now be able to use the iLogic parameter SketchText to change the text on your part.

Now click on the Emboss tool and select the text. Set the Depth at .05, and either Emboss or Engrave –whichever trips your trigger. When you finish, go back to the SketchText parameter and give it a whirl.

That will wrap up the tutorial for this iLogic Rule. The file: TextoChango.zip contains the modified FastenMaster part as well as the little tutorial file called Numbers. If you get a material missing warning on the BIM file, skip the material and continue. I need to fix that….