I have a lisp routine that takes the first 2 blocks in a selection set and moves them 2 inches closer together. Sometimes the code works perfectly fine, other times it won't work at all even if I am dealing with the same set of blocks selected where it worked before. All my blocks are at least 24 inches apart, and I always select 2 or more blocks, so I don't think i need to worry about those issues. Here is my code:
(defun c:HDM ()
(setq HDS (ssget '((0 . "INSERT"))))
(setq HDDa (ssname HDS 0))
(setq HDDb (ssname HDS 1))
(setq HDa (entget (ssname HDS 0)))
(setq HDb (entget (ssname HDS 1)))
(setq insA(cdr (assoc 10 HDa)))
(setq insB(cdr (assoc 10 HDb)))
(setq angA (angle insA insB) )
(setq angB (angle insB insA) )
(setq pt1 (polar insA angA 2))
(setq pt2 (polar insB angB 2))
(command "._move" HDDa "" insA pt1)
(command "._move" HDDb "" insB pt2)
(princ)
)
Any thoughts on where I may have gone wrong?
Solved! Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Most likely running OSNAP modes.
(defun c:HDM () (setq HDS (ssget '((0 . "INSERT")))) (setq HDDa (ssname HDS 0)) (setq HDDb (ssname HDS 1)) (setq HDa (entget (ssname HDS 0))) (setq HDb (entget (ssname HDS 1))) (setq insA(cdr (assoc 10 HDa))) (setq insB(cdr (assoc 10 HDb))) (setq angA (angle insA insB) ) (setq angB (angle insB insA) ) (setq pt1 (polar insA angA 2)) (setq pt2 (polar insB angB 2)) (command "._move" HDDa "" "_non" insA "_non" pt1) (command "._move" HDDb "" "_non" insB "_non" pt2) (princ) )
Other possible issues - UCS, variables not localized.
The OSNAP setting were throwing it off. Everything works perfectly as intended.
Can't find what you're looking for? Ask the community or share your knowledge.