I need a lisp that will round a number in autocad to the nearest 0.05, I have a numerous drawings with bench levels for lots (civil), I would like to be able to swipe multiple pieces of text and round them all to nearest 0.05.
;;; Written by Doug Broad;;; If value given 'to' argument is a real, a real is returned.;;; Rounds to nearest multiple of 'to' real or integer.(defun round (value to / try) (setq to (abs to)) (* to (fix (/ ((if (minusp value) - +) value (* to 0.5)) to)))); examples:; (round 12232e-015 1); 0; (round 12232e-015 1.0); 0.0; (round 123.6 1.0); 124.0; (round -123.6 1.0); -124.0; (round 6.00000000008 4); 8; 6.00000000008 rounded to the nearest multiple of 4 is 8
You need to use the original code, look at the examples. To round 1.2345 to the nearest 0.05 enter (round 1.2345 0.05)
It's set up this way so you can easily call it from another routine using the "value" you want to round and the "to" you want it rounded to.
A command function that starts with "c:" cannot have the "value" and "to" arguments. For a command function you would have to add prompts for and save those values.