Jump to content

Aligning leaders lisp


asami586

Recommended Posts

I get a lisp aligning leaders.

But this lisp works for Only 3 point leaders.

Could this lisp works for both 2 point leaders and 3 point leaders??

Please Help me.

 

 

;;; aligns the landings of selected 3 point leaders to a picked point or selection of leader
;;; and makes landing horizontal (if not already)
;;; [url]https://www.theswamp.org/[/url]


(defun c:DD (/ c# crds doc e ins newpt obj ss txt x y sel)
 (vl-load-com)
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (initget 0 "Leader PickPoint")
 (if (= (cond ((getkword
                 (strcat "\n Align by [Leader/PickPoint] <Leader>: ")
               )
              )
              ("Leader")
        )
        "Leader"
     )
   (and (setq e (car (entsel "\nSelect leader for alignment: ")))
        (setq x (cadr (assoc 10 (reverse (entget e)))))
   )
   (setq x (car (getpoint "\nSelect point for alignment: ")))
 )
 (if (and x (setq ss (ssget '((0 . "leader")))))
   (progn (vla-endundomark doc)
          (vla-startundomark doc)
          (foreach l (vl-remove e
                                (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
                     )
            (setq obj  (vlax-ename->vla-object l)
                  crds (vlax-get obj 'coordinates)
                  c#   (length crds)
            )
            (if (and (= c# 9) ;if leader has 3 points and /= x coord
                     (not (equal x (nth (- c# 3) crds) 0.0001))
                )
              (progn (setq y     (nth (- c# 5) crds) ;new y coord to ensure flat landing
                           newpt (list x y (nth (1- c#) crds))
                     )
                     (vlax-put obj
                               'coordinates
                               (append (reverse (cdddr (reverse crds))) newpt)
                     )
                     (vla-update obj)
                     (and (setq txt (vl-catch-all-apply ;has text attached to leader
                                      'vlax-ename->vla-object
                                      (list (cdr (assoc 340 (entget l))))
                                    )
                          )
                          (not (vl-catch-all-error-p txt)) ;check for invalid ename
                          (setq ins (vlax-get txt 'insertionpoint))
                          (vlax-put txt
                                    'insertionpoint
                                    (polar (list x (cadr ins) (caddr ins))
                                           (if (> x (nth (- c# 3) crds))
                                             0.
                                             pi
                                           )
                                           (if (zerop (getvar 'tilemode))
                                             (vla-get-textgap obj)
                                             (* (getvar 'dimscale) (vla-get-textgap obj))
                                           )
                                    )
                          )
                          (vla-update txt)
                     )
              )
            )
          )
          (vla-endundomark doc)
   )
 )
 (princ)
)

Edited by SLW210
Added Code Tags
Link to comment
Share on other sites

  • 2 months later...

Hello, do you have any method can align leader as same angle , because my job need to align over 300 leader as same angle for drawing

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...