Here's another one, concerning the same inaccurate drawing. Now I have all block instances rounded into a 5mm-accuracy.
Does anyone have a glue how to also round in Line start and end points (and maybe even polyline vertices) into a 1mm (or custom) accuracy. There are hundreds of inaccurate line elements within the drawing !!
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
Here is a generalised version of the previous program:
(defun c:round ( / e i k l m s ) (setq l '( ("CIRCLE" 10 40) ("LINE" 10 11) ("LWPOLYLINE" 10) ("INSERT" 10) ("POINT" 10) ) ) (if (null *tol*) (setq *tol* 5.0) ) (initget 6) (if (setq m (getreal (strcat "\nSpecify rounding tolerance <" (rtos *tol*) ">: "))) (setq *tol* m) (setq m *tol*) ) (if (setq s (ssget "_:L" '((0 . "CIRCLE,LINE,LWPOLYLINE,INSERT,POINT")))) (repeat (setq i (sslength s)) (if (setq e (entget (ssname s (setq i (1- i)))) k (cdr (assoc (cdr (assoc 0 e)) l)) ) (entmod (rounddxf k m e)) ) ) ) (princ) ) (defun rounddxf ( key mod lst / rtn ) (foreach itm lst (if (member (car itm) key) (setq rtn (cons (cons (car itm) (roundvalue (cdr itm) mod)) rtn)) (setq rtn (cons itm rtn)) ) ) (reverse rtn) ) (defun roundvalue ( val mod ) (if (listp val) (mapcar '(lambda ( x ) (round x mod)) val) (round val mod) ) ) ;; Doug Broad (defun round ( value to ) (setq to (abs to)) (* to (fix (/ ((if (minusp value) - +) value (* to 0.5)) to))) ) (princ)
@AIGmbH wrote:
....
Does anyone have a glue how to also round in Line start and end points (and maybe even polyline vertices) into a 1mm (or custom) accuracy. There are hundreds of inaccurate line elements within the drawing !!
This has come up here before. For instance, this thread, but I think there are more if you Search a little.
Another seamlessly working script!
This is exactly what I was looking for. An wholistic approach to the "snap to grid" problem - at least for the basic drawing elements that I was struggling with. When it comes to architectural elements like walls and foils the script would have to be further extended, but I guess even this would be possible.
Thank you!
Perfect.
This is exactly what I was looking for.
I would need small modification.
For my geodetic plan I need to round even numbers always up
e.g.
if rounding tolerance = 0.01
then results should be following:
1.134 -> 1.13
1.135 -> 1.14
1.136 -> 1.14
1.141 -> 1.14
1.145 -> 1.14
1.149 -> 1.14