4 Replies Latest reply on Apr 22, 2013 9:53 AM by David Spencer

    Equations

    David Spencer

      Is it possible to creat a n equation that will automaticly round the size up?

      Example: D14@SideSk = D12@TopSk to the next Nominal number. Rounded

      So if D14=34.485 it would round the part up to 34.500" or even 35.000"

      I know i can override the Dim in the drawing or set the Primary precision to none or .1 but that still leaves the part at 34.485

        • Re: Equations
          John Burrill

          David, you can use an IF statement with the INT operator to round numbers.

          For example  where D`1 is an equation-driven dimension and D2 is an input value

          =if("D2@Sketch10"-int("D2@Sketch10")>0.5,int("D2@Sketch10")+1,int("D2@Sketch10"))

          -will round the dimension to the nearest whole number

          If you want to introduce significant digits, just multiply the input value by 10^x power where x is the number of significant digits.

          Sof for example, if in the above case I wanted to round the result to two significant digits, I'd enter the value as

          =if(100*"D2@Sketch10"-int(100*"D2@Sketch10")>0.5,int((100*"D2@Sketch10")+1)/100,int(100*"D2@Sketch10")/100)

          For the purposes of making the equation easier to edit, I probably would split out the pieces into a couple of seperate equations

          For example

          Global variable: Sig_digits; Value: 2

          global variable:primer; equation: =10 ^ sig_digits

          and then rewrite the equation so that all I have to change is the sig_digits value to adjust the precision of the equations.

          Try it out.

          John

          • Re: Equations
            Jason Capriotti

            In addition to John's suggestion, you can use a "Round" operation.

             

            round ("a")

             

             

            a = 34.485

            b = round ("a")     ' =  34 (Rounds to the nearest whole number)

            c = round ("a",2)  ' =  34.48 (Rounds to two decimeal places)

            d = iif ( round ( "A" ) < "A" , round ( "A" ) + 1 , round ( "A" ) ) 'This would always round up to the nearest whole number.

            • Re: Equations
              David Spencer

              Thanks for the help guys. Works like a charm.