points,lines,polylines,splines
Hello.Does anyone have a routine that would round the coordinates of selected points,lines,polylines and splines to 2 decimal places(not just cut the rest of decimal places but ROUND it, so .384=.38 and .385=.39) and move them to that coordinates.That applies to height also. In case of polys and splines the vertices should also be rounded... thanx You can parse through your entities one by one with a while loop and use the following syntax
(atof (rtos 0.384 2 2))
An example for lines and points would be as follows. You will need to elaborate a bit for other kinds of entities but the principle is the same.
(defun fixl (/ round_decimals ss cnt pt10 pt11 lndt)(setq round_decimals 6)(if (setq ss (ssget "_A" '((-4 . "")))) (progn (setq cnt (sslength ss)) (while (>= (setq cnt (1- cnt)) 0) (setq lndt (entget (ssname ss cnt))) (setq pt10 (mapcar 'atof (mapcar '(lambda (x) (rtos x 2 round_decimals)) (cdr (assoc 10 lndt))))) (setq lndt (subst (cons 10 pt10) (assoc 10 lndt) lndt)) (entmod lndt) (if (assoc 11 lndt) ; this condition is used for lines (progn (setq pt11 (mapcar 'atof (mapcar '(lambda (x) (rtos x 2 round_decimals)) (cdr (assoc 11 lndt))))) (setq lndt (subst (cons 11 pt11) (assoc 11 lndt) lndt)) (entmod lndt) ) ) ) ))) I posted an example here some time ago:
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-of-line-and-pline-vertices/m-p/4396563#M314796
Awesome routine, Lee!
I've found that thread some time ago, but then I lost it and couldn't find it again, thanks for reposting it ! Thanks! thank you all for your help, I guess I'll try to implement rounding for splines too, if that's possible...
页:
[1]