please go through the modified code
@Anonymous wrote:
can you please modify below points in it:
1) I want to put arrow, arc & text in different layers ( "solid" for arrow, " Ref. line" for arc & "Ref. No." for text ).
2) I want to place text manually.
Thanks in advance.
(vl-load-com)
;; Changes ML into arc with arrowhead + text
;;
;; To change the arrow size or text size, type "mleaderstyle" on the command line
;; This will bring up the multiLeader style manager
;; Select the "Arc" Style from the list on the left side and press the "Modify" Button
;; On the next pop up, the arrowhead size can be changed on the "Leader Format" Tab;
;; and the text size on the "Content" Tab
;;
;; written by : Ron Harman (2015)
;; V2 updated some algorithms to VLisp (2017)
;;
;; Type ml2arc to run
;;
(defun c:ml2arc ( / *error* c_doc ms c_mls cmls mls_lst ml_txt pt1 a_obj e_pt s_pt pt2 pt3 ml_ent ml_obj c_obj minExt maxExt ss)
(defun *error* ( msg )
(if cmls (setvar 'cmleaderstyle cmls))
(if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error occurred : " msg)))
(princ)
);end_defun *error*
(setq c_doc (vla-get-activedocument (vlax-get-acad-object))
ms (vla-get-modelspace c_doc)
c_mls (vla-item (vla-get-dictionaries c_doc) "ACAD_MLEADERSTYLE")
);end_setq
;construct list of MLeader style names present in drawing
(vlax-for itm c_mls (setq mls_lst (cons (vlax-get itm 'name) mls_lst)))
;If MLStyle "Arc" not in drawing Alert and exit
(cond ( (not (member "Arc" mls_lst))
(alert "MLeader Style \"Arc\" NOT present in drawing. Exiting..")
(exit)
)
);end-cond
;If MLStyle "Arc" not current Style -> Save current Style and set "Arc" current
(cond ( (/= "Arc" (getvar 'cmleaderstyle))
(setq cmls (getvar 'cmleaderstyle))
(setvar 'cmleaderstyle "Arc")
)
);end_cond
(if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
(vla-startundomark c_doc)
(setq ml_txt (getstring T "\nEnter Leader Text : ")
pt1 (getpoint "\nSelect Arrowhead point for Arc : ")
);end_setq
(command "_Arc" pt1 pause pause)
(setq ml_ent_arc (entlast))
(command "_.chprop" ml_ent_arc "" "LA" "Ref. line" "")
(setq a_obj (vlax-ename->vla-object (entlast))
e_pt (vlax-curve-getendpoint a_obj)
s_pt (vlax-curve-getstartpoint a_obj)
pt2 (vlax-curve-getpointatdist a_obj (/ (vlax-get-property a_obj 'arclength) 2))
);end_setq
(if (equal pt1 e_pt 0.001) (setq pt3 s_pt) (setq pt3 e_pt))
(command "_mleader" pt1 pt2 pt3 ml_txt)
(setq ml_ent (entlast)
ml_obj (vlax-ename->vla-object ml_ent)
c_obj (vla-addcircle ms (vlax-3d-point pt1) (vlax-get-property ml_obj 'arrowheadsize))
i_pt (vlax-invoke a_obj 'intersectwith c_obj acExtendNone)
r_ang (angle i_pt pt1)
);end_setq
(vla-delete c_obj)
(vla-getboundingbox ml_obj 'minExt 'maxExt)
(setq minExt (reverse (cdr (reverse (vlax-safearray->list minExt))))
maxExt (reverse (cdr (reverse (vlax-safearray->list maxExt))))
);end_setq
(command "_explode" ml_ent)
(setq ss (ssget "_W" minExt maxExt (list '(0 . "INSERT,MTEXT,*LINE"))))
(vlax-for obj (vla-get-activeselectionset c_doc)
(cond ( (wcmatch (vlax-get-property obj 'objectname) "*MText")
(command "_.chprop" (vlax-vla-object->ename obj) "" "LA" "Ref. No." "")
(command "move" (vlax-vla-object->ename obj) "" (cdr (assoc 10 (entget (vlax-vla-object->ename obj)))))
(command "_explode" (vlax-vla-object->ename obj))
)
( (wcmatch (vlax-get-property obj 'objectname) "*BlockReference")
(command "_.chprop" (vlax-vla-object->ename obj) "" "LA" "solid" "")
(vlax-put-property obj 'rotation r_ang)
)
(t
(vla-delete obj)
)
);end_cond
);end_for
(setq ss nil)
(if cmls (setvar 'cmleaderstyle cmls))
(if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
(princ)
);end_defun
Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....