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…

 

Inventor iLogic Rounding Tutorial Image 02 - An Autodesk Inventor tutorial for creating driven dimensions

This information is contained within a Layout Part, and is passed to components created from the Layout Part, then fed to iProperties in those components, and are read at the drawing level by a Automatic Cutlist. The procedure is very simple, but I’ve had lots of people contact me with problems.  The most common is using the Snippet > Math > Round Closest to Increment incorrectly. The raw snippet is as follows…

 

Inventor iLogic Rounding Tutorial Image 02 - iLogic code snippet for rounding shown in this tutorial for creating cutlists

 What people do is see the blue d0 in the equation, and believe that all they need to do is replace that with their parameter and the parameter will now be rounded to a fraction…

 

Inventor iLogic Rounding Tutorial Image 03 - This image for iLogic Code shows the wrong way to create a rounding formula

 Which is wrong, and in this particular case, is wrong for a couple reasons. Firstly the formula is reading the parameter in that position, then doing the math, then outputting the answer to  the variable at the beginning of the formula, roundedClosest. The other problem is that the Corner_Bracket_Length parameter is a reference parameter and cannot be modified by anything other than changes to the geometry the dimension is attached to.

In the model in question here, we will be returning the value of the rounded Corner_Bracket_Length parameter to a parameter, Fractional_Bracket_Length, instead of a variable…

 

Inventor iLogic Rounding Tutorial Image 04 - This is the final Autodesk Inventor iLogic code for creating cutlists

 The value of the Fractional_Bracket_Length is then used in the Cutlist

 

 

 

Inventor iLogic Rounding Tutorial Image 05 - An automatically generated cutlist for woodworkers using Autodesk Inventor

 That’s all there is to it. There are a bazillion more iterations that can be used to meet your particular needs –there is no such thing as one size fits all in parametric design, especially in Autodesk Inventor iLogic!

 



Subsribe to Post Notifications


 





5 thoughts on “Inventor iLogic – Rounding Decimals to Nearest Fraction

  1. Hi Mark, Almost there but only the lengths of the end/side aprons to do. Are they calculated simply by the overall width/overall length minus 2"? Or do you creat parameters named End/Side_Apron_Length from driven dimensions (eg Tenon_Length and Apron_Length) inserted into the Sub Top Sketch and Tenon Profile Sketch and calculate their values by adding the driven dimensions and then multiplying by two.

    • Hi William,

      Glad to hear you are getting close! Congratulations, you are mostly correct:

      For both apron lengths, I added a driven dimension in the Tenon_Profile_Sketch ( the aprons should be projected into there). The dimensions go from the tip of the tenon to the end of the apron half. I called them Side_Apron_Half and End_Apron_Half, and their equation is simply multiplied by two as you had guessed.

      When you need a driven dimension like this, its best to do the whole thing in one fell swoop. If what you need isn’t in any particular sketch, project it into the one that is closest, or create a new one and do it there. Wherever possible, project sketch geometry, not faces or edges of solids.

      I will likely go back and split the top into separate boards –the number of which changes based on size, then output that to a glue-up schedule. Good luck finishing up!

      Mark

Leave a Reply