I have a problem rounding numbers to zero. I’ve written a python script to produce g code, the moves are modal so only get output when they change the trouble is sometimes I get a -0.00 like in this example. Ypt shows -0.00
Dunno, you might just need to run the numbers through a filter before formatting like:
import Rhino.RhinoMath as rm
if rm.EpsilonEquals(num_to_check,0,rm.SqrtEpsilon): num_to_check=0
#can substitute something other than SqrtEpsilon for tolerance level
Thanks for the pointers. I came up with this function that seem to work.
def RoundCoodinate(n, p = 3):
"""Rounds number to precision and returns a string
Parameters:
n = Number to round
p = 3 Precision Optional
"""
P = '{:.' + str(p) + 'f}'
n = round(n, p)
return(P.format(n if n != 0 else abs(n)))