Try this routine and let me know how things went on with you .
- (defun c:Test (/ doc *error* ColorTo104 lst s) ;; Author : Tharwat AL Shoufi ;; ;; www.CadTutor.com 11.Oct.2013 ;; (or doc (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) ) (defun *error* (u) (if lst (foreach it lst (vla-put-lock (vla-item (vla-get-layers doc) it) :vlax-true) ) ) (princ "\n *Cancel*") ) (defun ColorTo104 (ent) (if (eq 3 (vla-get-color ent)) (vla-put-color ent 104) ) ) (vlax-for l (vla-get-layers doc) (ColorTo104 l) (if (eq :vlax-true (vla-get-lock l)) (progn (vla-put-lock l :vlax-false) (setq lst (cons (vla-get-name l) lst)) ) ) ) (vla-startUndomark doc) (vlax-for b (vla-get-blocks doc) (if (and (eq :vlax-false (vla-get-IsXref b)) (eq :vlax-false (vla-get-IsLayout b)) ) (vlax-for x b (ColorTo104 x) ) ) ) (if (ssget "_X" '( (-4 . "") ) ) (progn (vlax-for e (setq s (vla-get-ActiveSelectionSet doc)) (if (and (eq (vla-get-objectname e) "AcDbBlockReference") (eq :vlax-true (vla-get-hasattributes e)) ) (foreach att (vlax-invoke e 'GetAttributes) (ColorTo104 att) ) (ColorTo104 e) ) ) (vla-delete s) ) ) (if lst (foreach u lst (vla-put-lock (vla-item (vla-get-layers doc) u) :vlax-true) ) ) (vla-regen doc AcActiveViewport) (vla-EndUndoMark doc) (princ))(vl-load-com)
|