Untested, but something like this.
;; Redefine All Blocks - Lee Mac
(defun c:redef-tender ( / bln dir1 dir2 doc dwg lst obj org spc )
(setq dir1 "C:\\000_Block\\Profile"); First Folder
(setq dir2 "C:\\000_Block\\Block"); Second Folder
(if dir1
(setq dir1 (strcat (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir1)) "\\"))
(setq dir1 "")
)
(if dir2
(setq dir2 (strcat (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir2)) "\\"))
(setq dir2 "")
)
(cond
( (= 4 (logand 4 (cdr (assoc 70 (tblsearch "layer" (getvar 'clayer))))))
(princ "\nCurrent layer locked.")
)
( (setq doc (vla-get-activedocument (vlax-get-acad-object))
spc (vla-get-modelspace doc)
org (vlax-3D-point 0 0)
)
(terpri)
(vlax-for blk (vla-get-blocks doc)
(if
(and
(= :vlax-false (vla-get-isxref blk))
(= :vlax-false (vla-get-islayout blk))
(wcmatch (strcase (setq bln (vla-get-name blk))) "08*,KG*")
); and
;; Check in First Folder
(if (setq dwg (findfile (strcat dir1 bln ".dwg")))
(progn
(princ (strcat "Redefining block: " dwg "\n"))
(setq obj (vla-insertblock spc org dwg 1.0 1.0 1.0 0.0))
(if (= :vlax-true (vla-get-hasattributes obj))
(setq lst (vl-list* "," bln lst))
); if
(vla-delete obj)
); progn
;; (princ (strcat "Unable to locate block: " dir1 bln ".dwg\n"))
); if
;; Check in Second Folder
(if (setq dwg (findfile (strcat dir2 bln ".dwg")))
(progn
(princ (strcat "Redefining block: " dwg "\n"))
(setq obj (vla-insertblock spc org dwg 1.0 1.0 1.0 0.0))
(if (= :vlax-true (vla-get-hasattributes obj))
(setq lst (vl-list* "," bln lst))
); if
(vla-delete obj)
); progn
;; (princ (strcat "Unable to locate block: " dir2 bln ".dwg\n"))
); if
;;
); if
;; loop
); vlax-for
(textscr)
(vla-regen doc acallviewports)
)
)
(princ)
)
(vl-load-com) (princ)
ECCAD