Howdy, I am looking for a lisp routine to add to search selected block/blocks to find any objects on layer "A-EquipLwr" and have them changed to layer "-PATT". Both layers are existing in the dwg, all the blocks have only 2 layers contained in them (A-EquipLwr and 0), but there are multiple variations of the block for different purposes. Does anyone have a lisp that will do this layer change in 1 step? Thank you in advance.
Note: I want to keep the layer name as it is, since it is connected to other objects in the drawing which are not a part of blocks.
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
Try the following quickly written code:
(defun c:fixblocks ( / a b f i l s ) (setq a "A-EQUIPLWR" b "-PATT" ) (defun f ( n / e x ) (if (and (not (member n l)) (setq e (tblobjname "block" n))) (progn (setq l (cons n l)) (while (setq e (entnext e)) (if (= (strcase a) (strcase (cdr (assoc 8 (setq x (entget e)))))) (entmod (subst (cons 8 b) (assoc 8 x) x)) ) (if (= "INSERT" (cdr (assoc 0 x))) (f (cdr (assoc 2 x)))) ) ) ) ) (if (setq s (ssget '((0 . "INSERT")))) (repeat (setq i (sslength s)) (f (cdr (assoc 2 (entget (ssname s (setq i (1- i))))))) ) ) (command "_.regen") (princ) )
Due to the recursive nature of the code, the above should also account for nested blocks, nested to any depth.
Excellent to hear! - You're most welcome ksmith
Hello All,
Would anyone know how to alter this lisp universally to select all and execute without user input ?
I'm am trying to just open the drawing and have it run automatically.
Thank you in advance ,