假设我已经理解了要求,下面是一个快速的Vanilla AutoLISP解决方案供您尝试:
- (defun c:nestblocklayer ( / blk def ent enx lay )
- (setq blk "bed" ;; Nested block name
- lay "mobilier" ;; New layer for nested blocks
- blk (strcase blk)
- )
- (while (setq def (tblnext "block" (not def)))
- (setq ent (tblobjname "block" (cdr (assoc 2 def))))
- (while (setq ent (entnext ent))
- (if
- (and
- (setq enx (entget ent))
- (= "INSERT" (cdr (assoc 0 enx)))
- (= blk (strcase (cdr (assoc 2 enx))))
- )
- (entmod (subst (cons 8 lay) (assoc 8 enx) enx))
- )
- )
- )
- (command "_.regenall")
- (princ)
- )
|