Jump to content
symoin

REDUCE THE LEADER LINE

Recommended Posts

symoin

Hi,

IS there a way or a code to reduce the line of the leader. Scale and trim won't work.

I have a drawing where there are many centerlines and there use to be a name for these centerlines and now the names are removed and the text is shortened in characters the leader line projects outside the text. 

I was looking for a way to edit or reduce the length upto the text. or any code.

Thanks in anticipation.

image.thumb.png.aca08bb3bea14fdae6ef0c37f7e923d0.png

Share this post


Link to post
Share on other sites
dlanorh

Attach a drawing of the above so everyone knows what they are dealing with (TEXT/MTEXT) etc and for testing.

Share this post


Link to post
Share on other sites
ReMark

Can we assume you are using Multileaders?

 

I believe that line is referred to as the landing or hook line.

 

Try setting the landing distance scale factor (default=1).  Do this through the Multileader Style Manager.  

 

 

Edited by ReMark
  • Like 1

Share this post


Link to post
Share on other sites
symoin
7 hours ago, dlanorh said:

Attach a drawing of the above so everyone knows what they are dealing with (TEXT/MTEXT) etc and for testing.

PLEASE FIND THE ATTACHED

LEADER-TEXT.dwg

Share this post


Link to post
Share on other sites
dlanorh

OK, try this

 

(defun rh:gbbu (obj / ll ur lst)
  (vlax-invoke-method obj 'getboundingbox 'll 'ur)
  (setq lst (mapcar 'vlax-safearray->list (list ll ur)))
  (cadr lst)
);end_defun

(vl-load-com)

(defun c:test ( / sel ent el ur obj nobj lst ept npt)
  (while (setq sel (entsel "\nSelect Leader Text : "))
    (setq el (entget (setq ent (car sel))) ur nil)
    (cond ( (= (cdr (assoc 0 el)) "TEXT") (setq ur (rh:gbbu (vlax-ename->vla-object ent))))
          ( (= (cdr (assoc 0 el)) "MTEXT")
            (setq obj (vlax-ename->vla-object ent)
                  nobj (vla-copy obj)
            );
            (vl-cmdf "explode" (vlax-vla-object->ename nobj) "")
            (setq nobj (vlax-ename->vla-object (entlast))
                  ur (rh:gbbu nobj)
            );end_setq
            (vla-delete nobj)
          )
    );end_cond
    (cond (ur
            (setq el (entget (setq ent (car (entsel "\nSelect Leader : ")))))
            (cond ( (= (cdr (assoc 0 el)) "LEADER")
                    (setq obj (vlax-ename->vla-object ent)
                          lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) el))
                          ept (last lst)
                          lst (cdr (reverse lst))
                          npt (list (car ur) (cadr ept) (caddr ept))
                          lst (reverse (cons npt lst))
                    )
                    (vlax-put obj 'coordinates (apply 'append lst))
                  )
            );end_cond
          )
    );end_cond
  );end_while
  (princ)
);end_defun

This works on your supplied drawing, and if the leader and text orientation are the same. You are ask to select the Leader Text, This can be "TEXT" or "MTEXT". You are then asked to select the Leader. This can only be a "LEADER" not an "MULTILEADER"

 

The loop will continue until you make a null selection (select a blank area of the screen) on the "Select Leader Text" prompt

  • Like 2

Share this post


Link to post
Share on other sites
symoin
On 9/13/2020 at 9:56 PM, dlanorh said:

OK, try this

 


(defun rh:gbbu (obj / ll ur lst)
  (vlax-invoke-method obj 'getboundingbox 'll 'ur)
  (setq lst (mapcar 'vlax-safearray->list (list ll ur)))
  (cadr lst)
);end_defun

(vl-load-com)

(defun c:test ( / sel ent el ur obj nobj lst ept npt)
  (while (setq sel (entsel "\nSelect Leader Text : "))
    (setq el (entget (setq ent (car sel))) ur nil)
    (cond ( (= (cdr (assoc 0 el)) "TEXT") (setq ur (rh:gbbu (vlax-ename->vla-object ent))))
          ( (= (cdr (assoc 0 el)) "MTEXT")
            (setq obj (vlax-ename->vla-object ent)
                  nobj (vla-copy obj)
            );
            (vl-cmdf "explode" (vlax-vla-object->ename nobj) "")
            (setq nobj (vlax-ename->vla-object (entlast))
                  ur (rh:gbbu nobj)
            );end_setq
            (vla-delete nobj)
          )
    );end_cond
    (cond (ur
            (setq el (entget (setq ent (car (entsel "\nSelect Leader : ")))))
            (cond ( (= (cdr (assoc 0 el)) "LEADER")
                    (setq obj (vlax-ename->vla-object ent)
                          lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) el))
                          ept (last lst)
                          lst (cdr (reverse lst))
                          npt (list (car ur) (cadr ept) (caddr ept))
                          lst (reverse (cons npt lst))
                    )
                    (vlax-put obj 'coordinates (apply 'append lst))
                  )
            );end_cond
          )
    );end_cond
  );end_while
  (princ)
);end_defun

This works on your supplied drawing, and if the leader and text orientation are the same. You are ask to select the Leader Text, This can be "TEXT" or "MTEXT". You are then asked to select the Leader. This can only be a "LEADER" not an "MULTILEADER"

 

The loop will continue until you make a null selection (select a blank area of the screen) on the "Select Leader Text" prompt

Thanks for the code,

This is working for the leader lines which are horizontal with 0 text rotation and its not working for the leaders and text which are not horizontal.

 

LEADER-TEXT-01.dwg

Edited by symoin
More information added

Share this post


Link to post
Share on other sites
dlanorh
20 hours ago, symoin said:

Thanks for the code,

This is working for the leader lines which are horizontal with 0 text rotation and its not working for the leaders and text which are not horizon

 

 

As I stated in my post. Do you also have leaders with text to the left of the main leader line?

Share this post


Link to post
Share on other sites
dlanorh

OK,  This should handle most cases.

 

(defun rh:gbbw (obj / ll ur lst wt)
  (if (and obj (= (type obj) 'ENAME))  (setq obj (vlax-ename->vla-object obj)))
  (vlax-invoke-method obj 'getboundingbox 'll 'ur)
  (setq lst (mapcar 'vlax-safearray->list (list ll ur)) wt (mapcar '(lambda (x y) (- x y)) (cadr lst) (car lst)))
  wt
);end_defun

(defun rh:z22pi (ar) (cond ( (equal ar (* pi 2.0) 1.0e-10) 0.0) ( (< -1.0e-16 ar (* pi 2.0)) ar) (t (rh:z22pi (rem (+ ar (* pi 2)) (* pi 2))))))

(vl-load-com)

(defun c:test ( / sel ent el w obj nobj tang ipt lel lent lst lang a b ept)
  (while (setq sel (entsel "\nSelect Leader Text : "))
    (setq el (entget (setq ent (car sel))) w nil nobj nil)
    (cond ( (= (cdr (assoc 0 el)) "TEXT")
            (setq obj (vlax-ename->vla-object ent) tang (rh:z22pi (cdr (assoc 50 el))) ipt (cdr (assoc 10 el)))
            (if (not (zerop tang)) (vlax-put obj 'rotation 0))
            (setq w (rh:gbbw obj))
            (if (not (zerop tang)) (vlax-put obj 'rotation tang))
          )
          ( (= (cdr (assoc 0 el)) "MTEXT")
            (setq obj (vlax-ename->vla-object ent)
                  tang (rh:z22pi (cdr (assoc 50 el)))
                  nobj (vla-copy obj)
            );end_setq
            (vl-cmdf "explode" (vlax-vla-object->ename nobj) "")
            (setq el (entget (setq ent (entlast))) ipt (cdr (assoc 10 el)) nobj (vlax-ename->vla-object ent))
            (if (not (zerop tang)) (vlax-put nobj 'rotation 0))
            (setq w (rh:gbbw nobj))
            (vla-delete nobj)
          )
    );end_cond

    (cond (w
            (setq w (car w)
                  lel (entget (setq lent (car (entsel "\nSelect Leader : "))))
            );end_setq
            (cond ( (= (cdr (assoc 0 lel)) "LEADER")
                    (setq obj (vlax-ename->vla-object lent)
                          lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) lel))
                          lang (rh:z22pi (angle (setq a (nth (- (length lst) 2) lst)) (setq b (last lst))))
                    );end_setq
                    (if (equal lang tang 1.0e-4) (setq ept (polar ipt tang w)) (setq ept ipt))
                    (setq ept (inters a b ept (polar ept (+ tang (* pi 0.5)) 5.0) nil)
                          lst (reverse (cons ept (cdr (reverse lst))))
                    )
                    (vlax-put obj 'coordinates (apply 'append lst))
                  )
            );end_cond
          )
    );end_cond
  );end_while
  (princ)
);end_defun

 

 

Share this post


Link to post
Share on other sites
symoin
21 hours ago, dlanorh said:

OK,  This should handle most cases.

 


(defun rh:gbbw (obj / ll ur lst wt)
  (if (and obj (= (type obj) 'ENAME))  (setq obj (vlax-ename->vla-object obj)))
  (vlax-invoke-method obj 'getboundingbox 'll 'ur)
  (setq lst (mapcar 'vlax-safearray->list (list ll ur)) wt (mapcar '(lambda (x y) (- x y)) (cadr lst) (car lst)))
  wt
);end_defun

(defun rh:z22pi (ar) (cond ( (equal ar (* pi 2.0) 1.0e-10) 0.0) ( (< -1.0e-16 ar (* pi 2.0)) ar) (t (rh:z22pi (rem (+ ar (* pi 2)) (* pi 2))))))

(vl-load-com)

(defun c:test ( / sel ent el w obj nobj tang ipt lel lent lst lang a b ept)
  (while (setq sel (entsel "\nSelect Leader Text : "))
    (setq el (entget (setq ent (car sel))) w nil nobj nil)
    (cond ( (= (cdr (assoc 0 el)) "TEXT")
            (setq obj (vlax-ename->vla-object ent) tang (rh:z22pi (cdr (assoc 50 el))) ipt (cdr (assoc 10 el)))
            (if (not (zerop tang)) (vlax-put obj 'rotation 0))
            (setq w (rh:gbbw obj))
            (if (not (zerop tang)) (vlax-put obj 'rotation tang))
          )
          ( (= (cdr (assoc 0 el)) "MTEXT")
            (setq obj (vlax-ename->vla-object ent)
                  tang (rh:z22pi (cdr (assoc 50 el)))
                  nobj (vla-copy obj)
            );end_setq
            (vl-cmdf "explode" (vlax-vla-object->ename nobj) "")
            (setq el (entget (setq ent (entlast))) ipt (cdr (assoc 10 el)) nobj (vlax-ename->vla-object ent))
            (if (not (zerop tang)) (vlax-put nobj 'rotation 0))
            (setq w (rh:gbbw nobj))
            (vla-delete nobj)
          )
    );end_cond

    (cond (w
            (setq w (car w)
                  lel (entget (setq lent (car (entsel "\nSelect Leader : "))))
            );end_setq
            (cond ( (= (cdr (assoc 0 lel)) "LEADER")
                    (setq obj (vlax-ename->vla-object lent)
                          lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) lel))
                          lang (rh:z22pi (angle (setq a (nth (- (length lst) 2) lst)) (setq b (last lst))))
                    );end_setq
                    (if (equal lang tang 1.0e-4) (setq ept (polar ipt tang w)) (setq ept ipt))
                    (setq ept (inters a b ept (polar ept (+ tang (* pi 0.5)) 5.0) nil)
                          lst (reverse (cons ept (cdr (reverse lst))))
                    )
                    (vlax-put obj 'coordinates (apply 'append lst))
                  )
            );end_cond
          )
    );end_cond
  );end_while
  (princ)
);end_defun

Thats perfect thanks a lot.

 

 

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...