@marko_ribar wrote:
.... My suggestion is that you change geometry and attribute under block into "0" Layer ....
That seems the best solution to me. If so, here's one that puts everything on Layer 0 including inside the definitions of nested Blocks. It's a modification of >this routine< that incorporates the omissions described in Message 18 there, so that it does not apply the color and linetype of each object's original Layer to it.
It ignores objects on the DEFPOINTS Layer, because that was part of the purpose on that thread, but it could easily be made to change those to Layer 0, too. It could also be made to force color and linetype to ByLayer, in case any objects may have overrides of such things that you want removed.
;; BENL0.lsp [command name the same]
;; = change all Block Entities [other than on Layer Defpoints] in selected Blocks'
;; definitions, including in any Nested Blocks, to Layer 0
;; Kent Cooper, edited 30 December 2019 [from BENL0CL.lsp]
(vl-load-com)
(defun C:BENL0CL (/ *error* nametolist doc blkss inc blokobj blkname blknames ent edata ldata)
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
(princ (strcat "\nError: " errmsg))
); if
(vla-endundomark doc)
(princ)
); defun - *error*
(defun nametolist (blk / blkobj blkname); get Block name and put it into list of names
(if (= (logand (cdr (assoc 70 (entget blk))) 4) 0) ; not an Xref
(progn
(setq
blkobj (vlax-ename->vla-object blk)
blkname
(vlax-get-property blkobj
(if (vlax-property-available-p blkobj 'EffectiveName) 'EffectiveName 'Name)
; to work with older versions that don't have dynamic Blocks
); ...get-property & blkname
); setq
(if
(not (member blkname blknames)); name not already in list
(setq blknames (append blknames (list blkname))); then -- add to end of list
); if
); progn
); if
); defun -- nametolist
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vla-startundomark doc); = Undo Begin
(if (setq blkss (ssget '((0 . "INSERT")))); User selection of any number of Blocks/Minserts/Xrefs
(progn; then
(repeat (setq inc (sslength blkss)); list of Block names from top-level selection
(nametolist (ssname blkss (setq inc (1- inc))))
); repeat
(while (setq blk (car blknames)); as long as there's another Block name in list
;; [this way instead of via (repeat) or (foreach), so it can add Nested Blocks' names to list]
(setq ent (tblobjname "block" blk)); Block definition as entity
(if (= (logand (cdr (assoc 70 (entget ent))) 4) 0) ; not an Xref
(while (setq ent (entnext ent)); then -- proceed through sub-entities in definition
(setq edata (entget ent))
(if (member '(0 . "INSERT") edata) (nametolist ent)); if nested Block, add name to end of list
(if (not (member '(8 . "Defpoints") edata)); process all entities NOT on Layer Defpoints
(progn ; then
(setq ldata (entget (tblobjname "layer" (cdr (assoc 8 edata))))); entity's Layer's properties
(setq edata (subst '(8 . "0") (assoc 8 edata) edata)); to Layer 0
(entmod edata)
); progn -- then
); if -- not on Defpoints
); while -- sub-entities
); if
(setq blknames (cdr blknames)); take first Block name off list
); while
(command "_.regen")
); progn
(prompt "\nNo Block(s) selected."); else
); if [user selection]
(vla-endundomark doc); = Undo End
(princ)
); defun
(prompt "\nType BENL0 to change all selected and nested Blocks' Entities to Layer 0.")
Kent Cooper, AIA