The below code searches for a titleblock, saves attribute values then deletes it. After inserting a new titleblock, the attribute values saved are applied to the new tb. The question is, how can I replace the (entsel) with the 'selection set' titleblock ?? (setq result nil) (vlax-for block (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (setq result (cons (vla-get-name block) result ) )) (foreach name (reverse result) (if (setq ss (ssget "X" (list '(0 . "INSERT")(cons 2 name)(cons 66 1)))) (if (not (or (or (findfile (strcat "N:/AutoCAD Support Files/Acco Standard Files/Standard Symbols/Symbols/" name ".dwg")) (findfile (strcat "N:/AutoCAD Support Files/" name ".dwg")) (findfile (strcat "N:/AutoCAD Support Files/Acco Standard Files/Standard Title Blocks/" name ".dwg")) )) ) (progn (defun get-att-val (TagNme / CurEnt CurObj RetVal) (vl-load-com) (if (setq CurEnt (car (entsel))) ; <--- replace this (progn (setq CurObj (vlax-ename->vla-object CurEnt)) (if (and (eq (vla-get-ObjectName CurObj) "AcDbBlockReference") (vla-get-HasAttributes CurObj) ) (mapcar '(lambda (Att)(if (eq TagNme (vla-get-TagString Att))(setq RetVal (vla-get-TextString Att)))) (vlax-invoke CurObj "GetAttributes")) ) ) ) RetVal ) (setq designation1 (get-att-val "DESCRIPTION_ONE")) (setq designation2 (get-att-val "DESCRIPTION_TWO")) (setq designation3 (get-att-val "DESCRIPTION_THREE")) (repeat (setq i (sslength ss))(vl-catch-all-apply 'vla-delete (list (vlax-ename->vla-object (ssname ss (setq i (1- i))))))) ) ) ) )
(if (setq CurEnt (car (entsel))) ; <--- replace this (progn ----------- (setq CurEnt ss); make a copy of ss (if CurEnt (progn Bob
Entsel only returns an entity. Selection sets are groups of entities (even only if there is one item in the selection set). You will either have to get the first entity or cycle through the selection set to process all entities. JRWalker