Originally Posted by
RenderMan
Tharwat -
If you're going to iterate the entire Selection Set, and covert each EName to Vla-Object, then you might consider instead simply iterating the ActiveSelectionSet Collection Object (just be sure to use the Delete Method on that Object's variable to remove from AutoCAD's available SelectionSet Objects).
Also, you might incorporate a StartUndoMark and EndUndoMark on the ActiveDocument Object, so the user can effectively reverse the changes made (if they so desire).
Cheers!
I should agree with you since every object in the selection set must be convert it to vla-object . so here it goes with vla functions .
Code:
(defun c:Test (/ style found ss)
;;; Tharwat 12. Aug. 2012 ;;;
(vl-load-com)
(defun *error* (msg)
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **"))
)
(princ)
)
(if (not acdoc)
(setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
)
(if (and (setq style (lisped "Enter Text style here "))
(setq found (tblsearch "style" style))
(ssget "_:L" '((0 . "*TEXT,MULTILEADER")))
)
(progn
(vla-StartUndoMark acdoc)
(vlax-for x (setq ss (vla-get-ActiveSelectionSet acdoc))
(if (eq (vla-get-objectname x) "AcDbMLeader")
(vla-put-textstylename x style)
(vla-put-stylename x style)
)
)
(vla-delete ss)
(vla-EndUndoMark acdoc)
)
(cond ((not found)
(alert "*** Text style is not found in the drawing ... ***")
)
(t (princ "\n Nothing selected ..."))
)
)
(princ)
)