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

LISP to move blocks closer to each other

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
kevin8UQA6
240 Views, 3 Replies

LISP to move blocks closer to each other

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?

3 REPLIES 3
Message 2 of 4
pendean
in reply to: kevin8UQA6

Can you share a DWG file with blocks where this LISP failed in?
Message 3 of 4
ВeekeeCZ
in reply to: kevin8UQA6

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.

Message 4 of 4
kevin8UQA6
in reply to: ВeekeeCZ

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.

Post to forums  

Forma Design Contest


AutoCAD Beta