从不建议分解任何方块,但请查看此处了解其余方块:http://www.cadtutor.net/forum/showthread.php?19161-lisp-for-changing-all-objects-in-a-block-to-layer-quot-0-quot
kbplc针对不同需求提供了多个版本。
还有一个版本:
- ; Written By: Tom Beauford
- ; Changes all block entities to layer "0" with color, linetype & lineweight ByBlock
- (defun C:FIXBLKS (/ *ERROR* SSET intCount ENAM ELST BNAM FLST FIX1)
- (setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
- (vla-startundomark thisdrawing)
- (defun *ERROR* (err) ; define local handler
- (vl-cmdf "undo" "Mark")
- (princ "\n\n")
- (princ)
- ); "" is the same message you get when exiting an AutoCAD command.
- (defun FIX1 (BNAM / BENAM BONAM)
- (if (not (member BNAM FLST))
- (progn
- (setq FLST (cons BNAM FLST)
- BENAM (tblobjname "block" BNAM)
- )
- (while (setq BENAM (entnext BENAM))
- (if (= (cdr (assoc 0 (entget BENAM))) "INSERT")
- (fix1 (cdr (assoc 2 (entget BENAM))))
- (progn
- (setq BONAM(vlax-ename->vla-object BENAM))
- (vl-catch-all-apply 'vla-put-layer (list BONAM "0"))
- (vl-catch-all-apply 'vla-put-color (list BONAM 0))
- (vl-catch-all-apply 'vla-put-linetype (list BONAM "Byblock"))
- (vl-catch-all-apply 'vla-put-Lineweight (list BONAM -2))
- (Eq,$(Getvar,PStyleMode),0),STB,CTB )
- (eq(getvar "PStyleMode")0)(vl-catch-all-apply 'vla-put-PlotStyleName (list BONAM "Byblock")))
- ; (vl-catch-all-apply 'vla-put-PlotStyleName (list BONAM "Byblock"))
- )
- )
- )
- )
- )
- )
- (setq SSET (ssget (list (cons 0 "INSERT"))))
- (repeat (setq intCount (sslength SSET))
- (setq intCount (1- intCount)
- ENAM (ssname SSET intCOunt)
- ELST (entget ENAM)
- BNAM (cdr (assoc 2 ELST))
- FLST nil
- )
- (fix1 BNAM)
- )
- (vl-cmdf "regen")
- (vla-endundomark thisdrawing)
- (princ)
- )
|