Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Rounding up block coordinates (insertion point)

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
AIGmbH
1242 Views, 3 Replies

Rounding up block coordinates (insertion point)

Maybe anyone has an idea on the following issue:

We have several AutoCAD drawings with hundreds of block references inserted with imprecise coordinates. Now we need to dimension all elements and need to correct these positions.

I am searching for a routine to round these positions up or down towards a 5mm precision so I don't have to manually move every single block element.

Is there any way to automate the task or do you know any workaround (like inserting the elements into a drawing with poorer unit precision settings)?

 

Thank you very much for your support!

Smiley Happy

3 REPLIES 3
Message 2 of 4
Lee_Mac
in reply to: AIGmbH

Try the following simple program:

 

(defun c:roundins ( / e i m p s x )
    (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 . "INSERT"))))
        (repeat (setq i (sslength s))
            (setq e (entget (ssname s (setq i (1- i))))
                  p (assoc 10 e)
            )
            (entmod (subst (cons 10 (mapcar '(lambda ( x ) (round x m)) (cdr p))) p e))
        )
    )
    (princ)
)

;; Doug Broad
(defun round ( value to )
    (setq to (abs to))
    (* to (fix (/ ((if (minusp value) - +) value (* to 0.5)) to)))
)
(princ)
Message 3 of 4
AIGmbH
in reply to: Lee_Mac

Brilliant!

Your script worked perfectly.

Thank you very much.

Smiley Wink

Message 4 of 4
Lee_Mac
in reply to: AIGmbH

You're welcome Smiley Happy

 

Be sure to mark the post as the accepted solution so as to indicate that the thread is resolved Smiley Wink

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost