;; Function to change bllocks to a layer by wildcard
(defun Blk2Lay (LName ss / n en eo)
(if (not (tblobjname "LAYER" LName)) ;Check if layer doesn't exist
(command "._LAYER" "_Make" LName "") ;Make the layer
) ;_ end of if
(setq n (sslength ss)) ;Initialize counter
(while (>= (setq n (1- n)) 0) ;Step through all entities in selection set
(setq en (ssname ss n) ;Get the nth EName
eo (vlax-ename->vla-object en) ;Get the ActiveX object
) ;_ end of setq
(vla-put-Layer eo LName) ;Change block reference to new layer
) ;_ end of while
) ;_ end of defun
;; Command to change blocks to a layer by wildcard
(defun c:Blk2Lay (/ LName BWild ss)
(if (setq LName (getstring "Enter the layer's name: ")) ;Get the layer's name
(if (and
(or
(and (= (setq BWild (getstring ;Get wildcard, default as layer name
(strcat "Enter the wildcard for the block name <*" LName "*>: ")
) ;_ end of getstring
) ;_ end of setq
""
) ;_ end of =
(setq BWild (strcat "*" LName "*")) ;Default to LName
) ;_ end of and
(and BWild (/= BWild ""))
) ;_ end of or
(setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BWild)))) ;And some blocks found
) ;_ end of and
(Blk2Lay LName ss) ;Perform the change
) ;_ end of if
) ;_ end of if
(princ)
) ;_ end of defun
Second - > I changed property of this layer to non visible.
Third - > I applied above changes on selected drawings.
Based on another example I found that there is possible to use LISP getfiles as well as ObjectDBX Wrapper which allow to use another function like below:
//This is example of script which remove blocks with name "KOLKO' from selected drawings
(defun c:dbtest ( / lst )
(if (setq lst (LM:getfiles "Select Drawings to Process" nil "dwg;dws;dwt"))