Rounding and Truncation

In capturing design intent and interactions of variables in I-DEAS, it is often useful to use Rounding and/or Truncation functions.  The challenge is that these functions operate slightly differently in various areas of I-DEAS.  We explain here, courtesy of information from David Sanz, how to use the functions and when.

I-DEAS Programmability

If you are doing direct computations in the Prompt window of I-DEAS, writing a program file (macro), or driving a program file through I-DEAS from an external application you will be wanting to "round" numbers using the "ent()" function.

#b = ent(a) -- returns the rounded value of a

In this case, I-DEAS does all the required units processing automatically and transparently.  An example that you can run by just typing into the prompt window:

/options units in -- (sets Units to "inches")
#a=11.125
#b=ent(a)
#output a ' ' b
    ==> 11.125 11   (correctly rounds down)

#a=11.875
#b=ent(a)
#output a ' ' b
    ==> 11.875 12   (correctly rounds up)

Part Equations

Units processing in the variational geometry system within parts needs to be specified explicitly.  Here the general form is:

b = round(a) -- returns the rounded value of a

This can be best illustrated via an example:

bulletopen a new model file
bulletApplication=Design, Task=Master Modeler
bulletOptions, Units, IN  (inches)
bulletParts... Block... Length=11.125...OK
bulletPart Equations
bulletb=round(Length)      (in the upper area of the form)
bulletinch   (in the lower right pulldown -- very important)
bulletApply


wrong answer

bulletEdit the Part Equations as below (i.e. convert Length to SI, round, and convert back to inches)... Apply:

correct answer

bulletOn the same form... edit Length to be 11.875... Apply... and you'll get the correct value for b of 12.

Assembly Equations

Assembly Equations follow much the same behavior as Part Equations (they both use the variational solver), with some some user interface nuances.   Here again the general form is:

b = round(a) -- returns the rounded value of a

Again and example:

bulletopen a new model file
bulletApplication=Design, Task=Master Modeler
bulletOptions, Units, IN  (inches)
bulletParts... Block... Length=11.125...OK
bulletModify... <pick the Length dimension>... change name to "Lengtha"
bulletName... "blocka"
bulletParts... Block... Length=5, Width=5, Depth=5...OK
bulletModify... <pick the Length dimension>... change name to "Lengthb"
bulletName... "blockb"
bulletTask=Master Assembly
bulletcreate an assembly containing the two blocks
bulletAssembly Equations...
bulletCreate... <pick the "Lengthb" dimension>
bulletround(Lengtha/.0254)*.0254   (i.e. convert Length to SI, round, and convert back to inches)
bullet<return>
bulletUpdate -- Lengthb will become 11 (correct)
bulletModify "Lengtha" to 11.875
bulletUpdate -- Lengthb will become 12 (correct)

Rounding to Fractional Numbers

In the part and assembly equation cases above, our technique was to convert current units to SI, round (or truncate), and then convert SI units back to current units, i.e.

b = round(a/factor)*factor -- returns the rounded value of "a" in desired units
where:

bulletwith "inches" as current units, factor = .0254
bulletwith "millimeters" as current units, factor = .001

If we want to round/truncate to a non-whole number, David Sanz gives us the trick here that can be used in any of the above situations (macros, parts, assemblies).  Our variable "factor" gets adjusted by the desired fraction.

Example:  Round to the nearest 1/4 inch

bulletfactor = .0254/4 = .000635
bulletb = round(a/.000635)*.000635
 

 
Back Up Next

back to WAMware homepage®
Copyright © 1996-