| |
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:
 | On 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:
 | open a new model file |
 | Application=Design, Task=Master Modeler |
 | Options, Units, IN (inches) |
 | Parts... Block... Length=11.125...OK |
 | Modify... <pick the Length dimension>... change name to "Lengtha" |
 | Name... "blocka" |
 | Parts... Block... Length=5, Width=5, Depth=5...OK |
 | Modify... <pick the Length dimension>... change name to "Lengthb" |
 | Name... "blockb" |
 | Task=Master Assembly |
 | create an assembly containing the two blocks |
 | Assembly Equations...
 | Create... <pick the "Lengthb" dimension> |
 | round(Lengtha/.0254)*.0254 (i.e. convert Length
to SI, round, and convert back to inches) |
 | <return> |
|
 | Update -- Lengthb will become
11 (correct) |
 | Modify "Lengtha" to 11.875 |
 | Update -- 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:
 | with "inches" as current units, factor = .0254 |
 | with "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
 | factor = .0254/4 = .000635 |
 | b = round(a/.000635)*.000635 |
|