symoin Posted September 13, 2020 Posted September 13, 2020 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. Quote
dlanorh Posted September 13, 2020 Posted September 13, 2020 Attach a drawing of the above so everyone knows what they are dealing with (TEXT/MTEXT) etc and for testing. Quote
ReMark Posted September 13, 2020 Posted September 13, 2020 (edited) 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 September 13, 2020 by ReMark 1 Quote
symoin Posted September 13, 2020 Author Posted September 13, 2020 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 Quote
dlanorh Posted September 13, 2020 Posted September 13, 2020 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 2 Quote
symoin Posted September 14, 2020 Author Posted September 14, 2020 (edited) 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 September 15, 2020 by symoin More information added Quote
dlanorh Posted September 15, 2020 Posted September 15, 2020 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? Quote
dlanorh Posted September 15, 2020 Posted September 15, 2020 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 Quote
symoin Posted September 16, 2020 Author Posted September 16, 2020 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. Quote
Recommended Posts
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.