lisp to move leaders along their length

lisp to move leaders along their length

prohlich
Explorer Explorer
373 Views
3 Replies
Message 1 of 4

lisp to move leaders along their length

prohlich
Explorer
Explorer

I'm looking for a lisp that will move all selected leaders along their length a given distance.

 

 

Carlson draws the top, the arrows are leaders.  I want to move them to look like the bottom.  I need to move hundreds of them on every project.  The rotation is inconsistent so they need to be moved based on the direction they were drawn.

 

I think I need the lisp to set the ucs to the leader (command "_ucs" "_Object")

then move the leader -3,0,0 (command "_move" "D" "-3,0,0")

 

thanks for any help

0 Likes
Accepted solutions (1)
374 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant

The Text is independent?

Would your 3 units always be appropriate in your usage, or would that vary with intended plotted scale?  Is the movement by the length of the arrowhead, or from the tip of the arrowhead to the overall midpoint of the Leader length?  [Your image looks like either could be the basis.]  Or some other standard?

Always single-segment Leaders?

Kent Cooper, AIA
0 Likes
Message 3 of 4

prohlich
Explorer
Explorer

The text is independent and should not move.  3 units (-3,0,0) will always be used regardless of anything else.  Movement will always be -3 in the x direction if the ucs is set to the leader object.  Always single segment leaders.

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

It's certainly not necessary to change the UCS.  For example:

(defun C:LM3 (/ ss n ldr verts); = Leader Move 3 units away from tip
  (if (setq ss (ssget "_:L" '((0 . "LEADER"))))
    (repeat (setq n (sslength ss)); then
      (setq
        ldr (ssname ss (setq n (1- n)))
        verts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ldr)))
      ); setq
      (command "_.move" ldr ""
        "_non" (car verts)
        "_non" (polar (car verts) (angle (car verts) (cadr verts)) 3)
      ); command
    ); repeat
  ); if
  (prin1)
)

 

Kent Cooper, AIA
0 Likes