;;;炸开选择中所有块,块炸到底
(defun c:bx()
(setvar "qaflags" 1)
(setq SS (ssget '((0 . "INSERT"))))
(setq n1 0)
(while (> (sslength SS) 0)
(command "explode" SS "")
(setq SB1 (ssget "p"))
(setq n2 0)
(setq SS (ssadd))
(repeat (sslength SB1)
(setq en(ssname SB1 n2))
(setq endata(entget en))
(setq entype (cdr (assoc 0 endata)))
(if (= entype "INSERT") (setq SS (ssadd en SS)))
(setq n2 (1+ n2))
)
(setq n1 (1+ n1))
)
(setvar "qaflags" 0)
(princ)
)
;;;块刷
(defun c:bc ( / old_cmd old_ent ss n e1 ee m)
(if (not (setq old_ent (ssget "_:S:E:L" '((0 . "INSERT"))))) (exit))
(setq old_ent (ssname old_ent 0))
(redraw old_ent 3)
(princ "\n 选择需被替换的块:")
(if (not (setq ss (ssget '((0 . "INSERT"))))) (exit))
(setq ee (assoc 2 (entget old_ent))
n (sslength ss)
m (itoa n)
)
(repeat n
(setq n (1- n) e1 (entget (ssname ss n)))
(entmod (subst ee (assoc 2 e1) e1))
)
(princ (strcat "\n " m " 个块被替换."))
)
(defun c:xx (/ *error* ss qf)
(defun *error* (msg)
(setvar "qaflags" qf)
(princ msg)
(princ)
)
(setq qf (getvar "qaflags"))
(setvar "qaflags" 1)
(princ "\n炸块")
(setq ss (ssget '((0 . "INSERT"))))
(while (setq ss (ssget "P" '((0 . "INSERT"))))
(command ".explode" ss "")
)
(setvar "qaflags" qf)
(princ)
)
G版_超级炸弹
(VL-LOAD-COM)
(setq *SYSVARNL* (LIST 'AUNITS 'AUPREC 'ATTDIA 'ATTREQ 'BLIPMODE 'DIMZIN 'CECOLOR
'CELTYPE 'CLAYER 'CMDECHO 'TRIMMODE 'EXPERT 'HIGHLIGHT 'LUNITS
'LUPREC 'EDGEMODE 'OSMODE 'ORTHOMODE 'TEXTSTYLE 'PLINEWID 'PLINEGEN
'FILEDIA 'PICKBOX 'QAFLAGS 'UCSAXISANG 'CELTSCALE 'NOMUTT
'PEDITACCEPT 'MIRRTEXT 'LIMCHECK
)
)
(setq *ACAD* (vlax-get-acad-object))
(setq *ACDOCUMENT* (vla-get-ActiveDocument *ACAD*))
(setq *MODEL-SPACE* (vla-get-ModelSpace *ACDOCUMENT*))
(setq *PAPER-SPACE* (vla-get-PaperSpace *ACDOCUMENT*))
(setq PI2 (* PI 0.5))
(setq PI4 (* PI 0.25))
(setq 2PI (* PI 2.0))
(setq 3PI2 (* 1.5 PI))
(setq 3PI4 (+ PI2 PI4))
(setq 5PI4 (+ PI PI4))
(setq 7PI4 (+ 3PI2 PI4))
(setq PI6 (/ PI 6))
(setq 2PI3 (/ PI 3 0.5))
(setq #ZJWS# 2)
(setq *JD* 1.0e-005)
(setq EN2OBJ vlax-ename->vla-object)
(setq OBJ2EN vlax-vla-object->ename)
(setq *SPACE* (vlax-get-property *ACDOCUMENT*
(if (= 1 (GETVAR 'CVPORT))
(PROGN 'PAPERSPACE)
(PROGN 'MODELSPACE)
)
)
)
(MAPCAR 'VL-ARX-IMPORT
'(ACAD_COLORDLG ACAD_TRUECOLORDLG ACAD_STRLSORT INITDIA acad-pop-dbmod
acad-push-dbmod STARTAPP LAYOUTLIST BPOLY
)
)
(DEFUN GXL-ITEM (COLL ITEM)
(if
(NOT
(VL-CATCH-ALL-ERROR-P
(setq ITEM (VL-CATCH-ALL-APPLY 'vla-Item (LIST COLL ITEM)))
)
)
(PROGN ITEM)
)
)
(DEFUN GXL-SYS-PROGRESS-DONE ()
(setq *PROGRESSID* 0)
(setq *PROGRESSTO* nil)
(setq *PROGRESSPROMPT* "")
(setq *PROGRESSBFB* 2)
(setq *FLAGINIT* nil)
(SETVAR "modemacro" "")
)
(DEFUN GXL-CATCHAPPLY (FUN ARGS / RESULT)
(if
(NOT
(VL-CATCH-ALL-ERROR-P
(setq RESULT (VL-CATCH-ALL-APPLY
(if (= 'SYM (TYPE FUN)) (PROGN FUN) (PROGN 'FUN))
ARGS
)
)
)
)
(PROGN RESULT)
)
)
(DEFUN GXL-REUCS (/ OBJUCS)
(if
(setq OBJUCS (GXL-CATCHAPPLY
vla-Item
(LIST (vla-get-UserCoordinateSystems *ACDOCUMENT*) "OldUCS")
)
)
(PROGN (vla-put-ActiveUCS *ACDOCUMENT* OBJUCS))
(PROGN (command "_.ucs") (command ""))
)
(PRINC)
)
(DEFUN REERR ()
(GXL-REUCS)
(if
(OR (= 'LIST (TYPE *ERROR*))
(= 'SUBR (TYPE *ERROR*))
(= 'USUBR (TYPE *ERROR*))
)
(PROGN
(MAPCAR '(lambda (A B) (VL-CATCH-ALL-APPLY 'SETVAR (LIST A B)))
*SYSVARNL*
(REVERSE *SVARL*)
)
(setq *ERROR* MYOLD*ERROR*)
)
(PROGN (ALERT "ERROR : NO (SETIERR)!"))
)
(if (= 8 (LOGAND (GETVAR "undoctl") 8)) (PROGN (vla-EndUndoMark *ACDOCUMENT*)))
(GC)
(PRINC)
)
(DEFUN GXL-PT->3D (P)
(COND
((= 'LIST (TYPE P))
(if (= 1 (LENGTH P))
(PROGN
(LIST
(if (= 'REAL (TYPE (CAR P)))
(PROGN (CAR P))
(PROGN (ATOF (ITOA (CAR P))))
)
0.0
0.0
)
)
(PROGN
(if (= 2 (LENGTH P))
(PROGN
(LIST
(if (= 'REAL (TYPE (CAR P)))
(PROGN (CAR P))
(PROGN (ATOF (ITOA (CAR P))))
)
(if (= 'REAL (TYPE (CADR P)))
(PROGN (CADR P))
(PROGN (ATOF (ITOA (CADR P))))
)
0.0
)
)
(PROGN
(LIST
(if (= 'REAL (TYPE (CAR P)))
(PROGN (CAR P))
(PROGN (ATOF (ITOA (CAR P))))
)
(if (= 'REAL (TYPE (CADR P)))
(PROGN (CADR P))
(PROGN (ATOF (ITOA (CADR P))))
)
(if (= 'REAL (TYPE (CADDR P)))
(PROGN (CADDR P))
(PROGN (ATOF (ITOA (CADDR P))))
)
)
)
)
)
)
)
((= 'REAL (TYPE P)) (LIST P 0.0 0.0))
((= 'INT (TYPE P)) (LIST (ATOF (ITOA P)) 0.0 0.0))
(T nil)
)
)
(DEFUN GXL-PT->SHIFT (PT @PT)
(setq PT (GXL-PT->3D PT))
(setq @PT (GXL-PT->3D @PT))
(APPLY 'MAPCAR (CONS '+ (LIST PT @PT)))
)
(DEFUN GXL-SETWCS (/ OBJUCS UCSORG UCSXDIR UCSYDIR)
(if (= 0 (GETVAR "worlducs"))
(PROGN (setq UCSORG (GETVAR "ucsorg"))
(setq UCSXDIR (GXL-PT->SHIFT UCSORG (GETVAR "ucsxdir")))
(setq UCSYDIR (GXL-PT->SHIFT UCSORG (GETVAR "ucsydir")))
(setq OBJUCS (VL-CATCH-ALL-APPLY 'vla-Item
(LIST (vla-get-UserCoordinateSystems *ACDOCUMENT* )
"OldUCS"
)
)
)
(VL-CMDF "_.ucs" "")
(if (NOT (VL-CATCH-ALL-ERROR-P OBJUCS)) (PROGN (vla-Delete OBJUCS)))
(VL-CATCH-ALL-APPLY 'vla-Add
(LIST (vla-get-UserCoordinateSystems *ACDOCUMENT*)
(vlax-3d-point UCSORG)
(vlax-3d-point UCSXDIR)
(vlax-3d-point UCSYDIR)
"OldUCS"
)
)
)
(PROGN
(setq OBJUCS (VL-CATCH-ALL-APPLY 'vla-Item
(LIST (vla-get-UserCoordinateSystems *ACDOCUMENT* )
"OldUCS"
)
)
)
(if (NOT (VL-CATCH-ALL-ERROR-P OBJUCS))
(PROGN (VL-CATCH-ALL-APPLY 'vla-Delete (LIST OBJUCS)))
)
)
)
(PRINC)
)
(DEFUN SETIERR (/ SV 0LAY OS)
(vla-put-Lock (GXL-ITEM (vla-get-Layers *ACDOCUMENT*) "0") :vlax-false)
(if (OR (= 'LIST (TYPE *ERROR*)) (= 'USUBR (TYPE *ERROR*)))
(PROGN (ALERT "ERROR :THE LAST (SETiERR) FUNCTION HAS NO (ReErr)!"))
(PROGN (setq *SVARL* nil)
(FOREACH SV *SYSVARNL* (setq *SVARL* (CONS (GETVAR SV) *SVARL*)))
(FOREACH SV
'("ATTDIA" "ATTREQ" "BLIPMODE" "CMDECHO" "DIMZIN" "OSMODE" "ORTHOMODE"
"MIRRTEXT"
)
(if (= SV "OSMODE")
(PROGN
(if (< (setq OS (GETVAR "OSMODE")) 16384)
(PROGN (SETVAR "OSMODE" (+ OS 16384)))
)
)
(PROGN (SETVAR SV 0))
)
)
(vla-StartUndoMark *ACDOCUMENT*)
(SETVAR "EXPERT" 5)
(SETVAR "CECOLOR" "BYLAYER")
(SETVAR "celtype" "BYLAYER")
(SETVAR "LWDISPLAY" 1)
(SETVAR "CELTSCALE" 1)
(SETVAR "PLINEGEN" 1)
(setq MYOLD*ERROR* *ERROR*)
(DEFUN *ERROR* (ST)
(while (and (/= (GETVAR 'CMDACTIVE) 0)) (command ""))
(GXL-SYS-PROGRESS-DONE)
(if ERRSEL (PROGN (command "erase") (command ERRSEL) (command "")))
(vla-EndUndoMark *ACDOCUMENT*)
(REERR)
(PRINC ST)
)
)
)
(GXL-SETWCS)
(setq *MODEL-SPACE* (vlax-get-property *ACDOCUMENT*
(if (= 1 (GETVAR 'CVPORT))
(PROGN 'PAPERSPACE)
(PROGN 'MODELSPACE)
)
)
)
)
(DEFUN GXL-SEL-MAPCAR (SS FUN / NN RTN)
(if SS
(PROGN
(REPEAT (setq NN (SSLENGTH SS))
(setq RTN (CONS (APPLY FUN (LIST (SSNAME SS (setq NN (1- NN))))) RTN))
)
)
)
)
(DEFUN GXL-LISTP (LST) (AND (VL-CONSP LST) (VL-LIST-LENGTH LST)))
(DEFUN GXL-DXF (ENT I)
(if (= (TYPE ENT) 'ENAME) (PROGN (setq ENT (ENTGET ENT '("*")))))
(COND
((ATOM I) (CDR (ASSOC I ENT)))
((GXL-LISTP I) (MAPCAR '(LAMBDA (X) (CDR (ASSOC X ENT))) I))
)
)
(DEFUN GXL-ITEMSALL (COLLECTION / RESULT)
(VL-CATCH-ALL-APPLY
'(lambda ()
(VLAX-FOR ITEM COLLECTION (setq RESULT (CONS ITEM RESULT)))
(REVERSE RESULT)
)
)
RESULT
)
(DEFUN GXL-STRPARSE (STR DEL / POS LST)
(while (and (setq POS (VL-STRING-SEARCH DEL STR)))
(setq LST (CONS (SUBSTR STR 1 POS) LST))
(setq STR (SUBSTR STR (+ POS 1 (STRLEN DEL))))
)
(if (= " " DEL)
(PROGN (VL-REMOVE "" (REVERSE (CONS STR LST))))
(PROGN (REVERSE (CONS STR LST)))
)
)
(DEFUN GXL-SEL-SS->VLA (SS / I L)
(if SS
(PROGN
(REPEAT (setq I (SSLENGTH SS))
(setq L (CONS (vlax-ename->vla-object (SSNAME SS (setq I (1- I)))) L))
)
)
)
)
(DEFUN GXL-SEL-ENTNEXTALL (ENT / SS)
(if (NOT ENT)
(PROGN (setq ENT (ENTNEXT))
(if ENT (PROGN (setq SS (SSADD ENT))) (PROGN (setq SS (SSADD))))
)
(PROGN (setq SS (SSADD)))
)
(while (and (setq ENT (ENTNEXT ENT)))
(if (NOT (MEMBER (CDR (ASSOC 0 (ENTGET ENT))) '("ATTRIB" "VERTEX" "SEQEND")))
(PROGN (SSADD ENT SS))
)
)
(if (= 0 (SSLENGTH SS)) (PROGN nil) (PROGN SS))
)
(DEFUN GXL-CH_ENT (ENT I PT / EN)
(if (ASSOC I (setq EN (ENTGET ENT)))
(PROGN (setq EN (SUBST (CONS I PT) (ASSOC I EN) EN)))
(PROGN (setq EN (APPEND EN (LIST (CONS I PT)))))
)
(ENTMOD EN)
)
(DEFUN GXL-SUPPEREXPLODEBLOCK (EN / SUPPEREXPLODEBLOCK SS LASTEN LAYER BLKREF)
(DEFUN SUPPEREXPLODEBLOCK (OBJ PARLST / ORIGIN X Y Z R INSERTPT COPYENT ATTS
STYLENAME DXF BLKOBJ E0 TXTOBJ TMP COPYS ROW COL ROWSPC
COLSPC
)
(setq ORIGIN (vlax-3d-point '(0 0 0)))
(if
(OR (= "AcDbBlockReference" (vla-get-ObjectName OBJ))
(= "AcDbMInsertBlock" (vla-get-ObjectName OBJ))
)
(PROGN (setq X (vla-get-XScaleFactor OBJ))
(setq Y (vla-get-YScaleFactor OBJ))
(setq Z (vla-get-ZScaleFactor OBJ))
(setq R (vla-get-Rotation OBJ))
(setq INSERTPT (vla-get-InsertionPoint OBJ))
(setq COPYENT (vlax-invoke *ACDOCUMENT*
'COPYOBJECTS
(VL-REMOVE-IF
'(LAMBDA (X)
(= "AcDbAttributeDefinition"
(vla-get-ObjectName X)
)
)
(GXL-ITEMSALL
(vla-Item (vla-get-Blocks *ACDOCUMENT*)
(vla-get-Name OBJ)
)
)
)
*MODEL-SPACE*
)
)
(if (= "AcDbMInsertBlock" (vla-get-ObjectName OBJ))
(PROGN (setq ROW (vla-get-Rows OBJ))
(setq ROWSPC (/ (vla-get-RowSpacing OBJ) Y))
(setq COL (vla-get-Columns OBJ))
(setq COLSPC (/ (vla-get-ColumnSpacing OBJ) X))
(setq TMP nil)
(setq COPYS COPYENT)
(REPEAT (1- ROW)
(setq COPYS (MAPCAR 'vla-Copy COPYS))
(MAPCAR
'(LAMBDA (M)
(vla-Move M
ORIGIN
(vlax-3d-point
(POLAR (QUOTE (0 0 0)) PI2 ROWSPC)
)
)
)
COPYS
)
(setq TMP (APPEND TMP COPYS))
)
(setq COPYS (APPEND COPYENT TMP))
(REPEAT (1- COL)
(setq COPYS (MAPCAR 'vla-Copy COPYS))
(MAPCAR
'(LAMBDA (M)
(vla-Move M
ORIGIN
(vlax-3d-point
(POLAR (QUOTE (0 0 0)) 0 COLSPC)
)
)
)
COPYS
)
(setq TMP (APPEND TMP COPYS))
)
(setq COPYENT (APPEND COPYENT TMP))
)
)
(if (vla-get-HasAttributes OBJ)
(PROGN (setq ATTS (vlax-invoke OBJ 'GETATTRIBUTES))
(FOREACH ATT ATTS
(setq STYLENAME (LAST
(GXL-STRPARSE
(vla-get-StyleName ATT)
"|"
)
)
)
(setq DXF (ENTGET (vlax-vla-object->ename ATT)))
(setq DXF (MEMBER '(100 . "AcDbEntity") DXF))
(setq DXF (CDR
(MEMBER '(100 . "AcDbAttribute")
(REVERSE DXF)
)
)
)
(setq DXF (CONS '(0 . "TEXT") (REVERSE DXF)))
(MAPCAR
'(LAMBDA (X) (SETQ DXF (VL-REMOVE (ASSOC X DXF) DXF)))
'(-1 5 330 7)
)
(setq DXF (SUBST (CONS 8 (GETVAR "clayer"))
(ASSOC 8 DXF)
DXF
)
)
(setq DXF (SUBST (CONS 62 256) (ASSOC 62 DXF) DXF))
(ENTMAKE DXF)
(vla-put-StyleName (setq TXTOBJ (vlax-ename->vla-object (ENTLAST ) ))
STYLENAME
)
(SUPPEREXPLODEBLOCK TXTOBJ PARLST)
)
)
)
(vla-Delete OBJ)
(setq PARLST (CONS (LIST X Y Z R INSERTPT) PARLST))
(FOREACH AOBJ COPYENT
(if
(OR (= "AcDbBlockReference" (vla-get-ObjectName AOBJ))
(= "AcDbMInsertBlock" (vla-get-ObjectName AOBJ))
)
(PROGN
(if (vla-get-HasAttributes AOBJ)
(PROGN (setq ATTS (vlax-invoke AOBJ 'GETATTRIBUTES))
(FOREACH ATT ATTS
(setq STYLENAME (LAST
(GXL-STRPARSE
(vla-get-StyleName ATT)
"|"
)
)
)
(setq DXF (ENTGET (vlax-vla-object->ename ATT)))
(setq DXF (MEMBER '(100 . "AcDbEntity") DXF))
(setq DXF (CDR
(MEMBER '(100 . "AcDbAttribute")
(REVERSE DXF)
)
)
)
(setq DXF (CONS '(0 . "TEXT") (REVERSE DXF)))
(MAPCAR
'(LAMBDA (X)
(SETQ DXF (VL-REMOVE (ASSOC X DXF) DXF))
)
'(-1 5 330 7)
)
(setq DXF (SUBST (CONS 8 (GETVAR "clayer"))
(ASSOC 8 DXF)
DXF
)
)
(setq DXF (SUBST (CONS 62 256) (ASSOC 62 DXF) DXF))
(ENTMAKE DXF)
(vla-put-StyleName (vlax-ename->vla-object (ENTLAST))
STYLENAME
)
(SUPPEREXPLODEBLOCK
(vlax-ename->vla-object (ENTLAST))
PARLST
)
)
)
)
(SUPPEREXPLODEBLOCK AOBJ PARLST)
)
(PROGN (setq COPYENT (LIST AOBJ))
(MAPCAR
'(LAMBDA (PARS / X Y Z R INSERTPT BLKOBJ E0)
(SETQ X (CAR PARS)
Y (CADR PARS)
Z (CADDR PARS)
R (CADDDR PARS)
INSERTPT (LAST PARS)
)
(SETQ BLKOBJ (vla-Add (vla-get-Blocks *ACDOCUMENT*)
ORIGIN
"*U"
)
)
(vlax-invoke *ACDOCUMENT*
(QUOTE COPYOBJECTS)
COPYENT
BLKOBJ
)
(MAPCAR (QUOTE vla-Delete) COPYENT)
(vla-InsertBlock *MODEL-SPACE*
INSERTPT
(vla-get-Name BLKOBJ)
X
Y
Z
R
)
(COMMAND "_.explode" (SETQ E0 (ENTLAST)))
(vla-Delete BLKOBJ)
(SETQ COPYENT (GXL-SEL-SS->VLA
(GXL-SEL-ENTNEXTALL E0)
)
)
)
PARLST
)
)
)
)
)
(PROGN (setq COPYENT (LIST OBJ))
(MAPCAR
'(LAMBDA (PARS / X Y Z R INSERTPT BLKOBJ E0)
(SETQ X (CAR PARS)
Y (CADR PARS)
Z (CADDR PARS)
R (CADDDR PARS)
INSERTPT (LAST PARS)
)
(SETQ BLKOBJ (vla-Add (vla-get-Blocks *ACDOCUMENT*) ORIGIN "*U"))
(vlax-invoke *ACDOCUMENT* (QUOTE COPYOBJECTS) COPYENT BLKOBJ)
(MAPCAR (QUOTE vla-Delete) COPYENT)
(vla-InsertBlock *MODEL-SPACE*
INSERTPT
(vla-get-Name BLKOBJ)
X
Y
Z
R
)
(COMMAND "_.explode" (SETQ E0 (ENTLAST)))
(vla-Delete BLKOBJ)
(SETQ COPYENT (GXL-SEL-SS->VLA (GXL-SEL-ENTNEXTALL E0)))
)
PARLST
)
)
)
)
(if (= 'ENAME (TYPE EN))
(PROGN (setq BLKREF (vlax-ename->vla-object EN)))
(PROGN (setq BLKREF EN) (setq EN (vlax-vla-object->ename EN)))
)
(if
(AND (= "INSERT" (GXL-DXF EN 0))
(NOT
(= 4
(LOGAND
(CDR
(ASSOC 70
(ENTGET (TBLOBJNAME "block" (CDR (ASSOC 2 (ENTGET EN)))))
)
)
4
)
)
)
)
(PROGN (setq LASTEN (ENTLAST))
(setq LAYER (vla-get-Layer BLKREF))
(SUPPEREXPLODEBLOCK BLKREF nil)
(setq SS (GXL-SEL-ENTNEXTALL LASTEN))
(GXL-SEL-MAPCAR SS '(LAMBDA (X) (GXL-CH_ENT X 8 LAYER)))
SS
)
(PROGN (SSADD EN))
)
)
(DEFUN GXL-ASSOC (KEY ALIST / VAL) (CDR (ASSOC KEY ALIST)))
(DEFUN GXL-BLK-VXGETATTS (OBJ)
(if (= (TYPE OBJ) 'ENAME) (PROGN (setq OBJ (vlax-ename->vla-object OBJ))))
(MAPCAR '(LAMBDA (ATT) (CONS (vla-get-TagString ATT) (vla-get-TextString ATT)))
(vlax-invoke OBJ "GetAttributes")
)
)
(DEFUN GXL-CODESTRIP (ENTL STRIPLST)
(VL-REMOVE-IF '(LAMBDA (A) (VL-POSITION (CAR A) STRIPLST)) ENTL)
)
(DEFUN GXL-STR-SUBST (NEW OLD STR / STR1 N)
(setq N (STRLEN OLD))
(COND
((> (STRLEN STR) N)
(setq STR1 (SUBSTR STR 1 N))
(if (= STR1 OLD)
(PROGN (STRCAT NEW (GXL-STR-SUBST NEW OLD (SUBSTR STR (1+ N)))))
(PROGN (STRCAT (SUBSTR STR 1 1) (GXL-STR-SUBST NEW OLD (SUBSTR STR 2))))
)
)
((= (STRLEN STR) N) (if (= OLD STR) (PROGN NEW) (PROGN STR)))
(T STR)
)
)
(DEFUN GXL-BLK-CHECK (B_NAME / $PROMPT B_NAME1 CURLAY ERR)
(if (OR (= 'SUBR (TYPE MAKEBLOCK-001)) (= 'USUBR (TYPE MAKEBLOCK-001)))
(PROGN)
(PROGN (setq $PROMPT (LOAD "MakeBlockSymbol.vlx" "未找到MakeBlockSymbol.vlx文件")))
)
(if (= $PROMPT "未找到MakeBlockSymbol.vlx文件")
(PROGN
(setq $PROMPT (LOAD "E:\\lisp\\房产CAD工具软件\\lisp\\MakeBlockSymbol.vlx"
"未找到MakeBlockSymbol.vlx文件"
)
)
)
)
(if (= $PROMPT "未找到MakeBlockSymbol.vlx文件")
(PROGN B_NAME)
(PROGN (setq B_NAME1 (GXL-STR-SUBST "]" ")" (GXL-STR-SUBST "[" "(" B_NAME)))
(setq CURLAY (GETVAR "Clayer"))
(setq ERR (VL-CATCH-ALL-APPLY 'vla-Item
(LIST (vla-get-Blocks *ACDOCUMENT*)
B_NAME
)
)
)
(if (VL-CATCH-ALL-ERROR-P ERR)
(PROGN
(if
(OR (= 'USUBR (TYPE (EVAL (READ (STRCAT "MakeBlock-" B_NAME1)))))
(= 'SUBR (TYPE (EVAL (READ (STRCAT "MakeBlock-" B_NAME1)))))
)
(PROGN (EVAL (READ (STRCAT "(MakeBlock-" B_NAME1 ")"))))
)
)
)
(SETVAR "clayer" CURLAY)
B_NAME
)
)
)
(DEFUN GXL-AX:INSERTBLOCK (INSPT NAME XSCALE YSCALE ZSCALE ROTATION)
(GXL-BLK-CHECK NAME)
(SETVAR "insname" (VL-FILENAME-BASE NAME))
(VL-CATCH-ALL-APPLY 'vla-InsertBlock
(LIST *MODEL-SPACE*
(vlax-3d-point (TRANS INSPT 1 0))
NAME
XSCALE
YSCALE
ZSCALE
ROTATION
)
)
)
(DEFUN GXL-BLK-VXSETATTS (OBJ LST / ATTVAL)
(if (= (TYPE OBJ) 'ENAME) (PROGN (setq OBJ (vlax-ename->vla-object OBJ))))
(MAPCAR
'(LAMBDA (ATT)
(IF (SETQ ATTVAL (CDR (ASSOC (vla-get-TagString ATT) LST)))
(vla-put-TextString ATT ATTVAL)
)
)
(vlax-invoke OBJ "GetAttributes")
)
(vla-Update OBJ)
(PRINC)
)
(DEFUN GXL-BLK-MINSERT->INSERT (EN / FLAG FLAG1 ENL ROT XSCALE YSCALE ZSCALE COL ROW
COLDIS ROWDIS INSPT NEWENLST I II COLPT ROWPT NAME
ATTS SS
)
(if
(AND EN
(if (= 'VLA-OBJECT (TYPE EN))
(PROGN (setq EN (vlax-vla-object->ename EN)))
(PROGN EN)
)
(= "INSERT" (CDR (ASSOC 0 (setq ENL (ENTGET EN '("*"))))))
(= "AcDbMInsertBlock" (CDR (ASSOC 100 (MEMBER (ASSOC 8 ENL) ENL))))
)
(PROGN (setq SS (SSADD))
(setq ROT (GXL-ASSOC 50 ENL))
(setq XSCALE (GXL-ASSOC 41 ENL))
(setq YSCALE (GXL-ASSOC 42 ENL))
(setq ZSCALE (GXL-ASSOC 43 ENL))
(setq COL (GXL-ASSOC 70 ENL))
(setq ROW (GXL-ASSOC 71 ENL))
(setq COLDIS (GXL-ASSOC 44 ENL))
(setq ROWDIS (GXL-ASSOC 45 ENL))
(setq INSPT (GXL-ASSOC 10 ENL))
(setq NAME (GXL-ASSOC 2 ENL))
(setq ATTS (GXL-BLK-VXGETATTS EN))
(setq NEWENLST (GXL-CODESTRIP ENL '(-1 330 5 70 71 44 45)))
(setq NEWENLST (SUBST '(100 . "AcDbBlockReference")
'(100 . "AcDbMInsertBlock")
NEWENLST
)
)
(setq I 0)
(REPEAT COL
(setq COLPT (POLAR INSPT ROT (* I COLDIS)))
(setq II 0)
(REPEAT ROW
(setq ROWPT (POLAR COLPT (+ ROT PI2) (* II ROWDIS)))
(setq OBJ (GXL-AX:INSERTBLOCK ROWPT NAME XSCALE YSCALE ZSCALE ROT))
(command "_matchprop")
(command EN)
(command (ENTLAST))
(command "")
(SSADD (ENTLAST) SS)
(if ATTS (PROGN (GXL-BLK-VXSETATTS OBJ ATTS)))
(setq II (1+ II))
)
(setq I (1+ I))
)
(ENTDEL EN)
SS
)
(PROGN (SSADD EN))
)
)
(DEFUN GXL-SEL-SS->LIST (SS / I S)
(if SS
(PROGN
(REPEAT (setq I (SSLENGTH SS)) (setq S (CONS (SSNAME SS (setq I (1- I))) S)))
)
)
)
(DEFUN GXL-CODESTRIPFIRST (LST STRIPLST)
(if LST
(PROGN
(if STRIPLST
(PROGN
(if (VL-POSITION (CAAR LST) STRIPLST)
(PROGN (GXL-CODESTRIPFIRST (CDR LST) (VL-REMOVE (CAAR LST) STRIPLST)))
(PROGN (CONS (CAR LST) (GXL-CODESTRIPFIRST (CDR LST) STRIPLST)))
)
)
(PROGN LST)
)
)
)
)
(DEFUN GXL-MATT2MTEXT (ELIST / EL)
(setq EL (ENTGET (CDR (ASSOC 330 ELIST))))
(setq ELIST (SUBST (ASSOC 8 EL) (ASSOC 8 ELIST) ELIST))
(if (ASSOC 66 EL)
(PROGN (setq ELIST (SUBST (ASSOC 66 EL) (ASSOC 66 ELIST) ELIST)))
)
(ENTMAKEX
(APPEND '((0 . "MTEXT") (100 . "AcDbEntity") (100 . "AcDbMText"))
(GXL-CODESTRIPFIRST
(GXL-CODESTRIP ELIST '(102 330 360 0 100 101 2 42 43 51 74 70 280))
'(40 1 50 41 7 71 72 71 72 73 10 11 11 210)
)
)
)
)
(DEFUN GXL-ATT2TEXT (ELIST / EL)
(setq EL (ENTGET (CDR (ASSOC 330 ELIST))))
(setq ELIST (SUBST (ASSOC 8 EL) (ASSOC 8 ELIST) ELIST))
(if (ASSOC 66 EL)
(PROGN (setq ELIST (SUBST (ASSOC 66 EL) (ASSOC 66 ELIST) ELIST)))
)
((lambda (DXF74)
(ENTMAKEX
(APPEND '((0 . "TEXT"))
(GXL-CODESTRIP
(SUBST (CONS 73 DXF74) (ASSOC 74 ELIST) ELIST)
'(0 100 2 74 70 280)
)
)
)
)
(CDR (ASSOC 74 ELIST))
)
)
(DEFUN GXL-EXPLODEBLOCK (EN / DOC MSPACE BLKS BLNAME BLKREF BLKDEF OBJLST OBJ INSPT
OBJARRAY OBJ ATTS OBJARRAY1 ATT DATA DATA1 DATA2 RTN SS
XSCALE YSCALE ZSCALE ROTATION NEWEN ENLAST RTN1
)
(setq DOC (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq MSPACE (vla-get-ModelSpace DOC))
(setq BLKS (vla-get-Blocks DOC))
(setq FLAG T)
(SETVAR "cecolor" "ByLayer")
(if (= 'VLA-OBJECT (TYPE EN)) (PROGN (setq EN (vlax-vla-object->ename EN))))
(setq SS (GXL-BLK-MINSERT->INSERT EN))
(setq SS (GXL-SEL-SS->LIST SS))
(FOREACH EN SS
(if (= "INSERT" (GXL-DXF EN 0))
(PROGN
(if
(= :vlax-true
(vla-get-HasAttributes (setq OBJ (vlax-ename->vla-object EN)))
)
(PROGN
(setq ATTS (vlax-safearray->list (vlax-variant-value (vla-GetAttributes OBJ ) ) ))
)
)
(if ATTS
(PROGN
(FOREACH ATT ATTS
(if (/= "" (vla-get-TextString ATT))
(PROGN
(if vla-get-MTextAttribute
(PROGN
(if (= :vlax-true (vla-get-MTextAttribute ATT))
(PROGN
(GXL-MATT2MTEXT (ENTGET (vlax-vla-object->ename ATT)))
)
(PROGN (GXL-ATT2TEXT (ENTGET (vlax-vla-object->ename ATT))) )
)
)
(PROGN (GXL-ATT2TEXT (ENTGET (vlax-vla-object->ename ATT))))
)
(setq OBJARRAY1 (CONS (vlax-ename->vla-object (ENTLAST))
OBJARRAY1
)
)
)
)
)
)
)
(setq INSPT (GXL-DXF EN 10))
(setq LAY (GXL-DXF EN 8))
(setq XSCALE (GXL-DXF EN 41))
(setq YSCALE (GXL-DXF EN 42))
(setq ZSCALE (GXL-DXF EN 42))
(setq ROTATION (GXL-DXF EN 50))
(setq BLKNAME (vla-get-Name (setq BLKREF (vlax-ename->vla-object EN))))
(if
(= "AcDbBlockReference" (vla-get-ObjectName (vlax-ename->vla-object EN)))
(PROGN (setq ENLAST (ENTLAST)) (command "_.explode") (command EN))
(PROGN (ENTDEL EN)
(setq ENLAST (ENTLAST))
(GXL-AX:INSERTBLOCK INSPT BLKNAME XSCALE YSCALE ZSCALE ROTATION)
(command "_.explode")
(command (ENTLAST))
)
)
(setq SS1 (GXL-SEL-ENTNEXTALL ENLAST))
(setq SS1 (GXL-SEL-SS->LIST SS1))
(setq SS1 (MAPCAR 'vlax-ename->vla-object SS1))
(MAPCAR '(LAMBDA (X) (vla-put-Layer X LAY)) SS1)
(setq RTN (APPEND RTN (APPEND OBJARRAY1 SS1)))
)
(PROGN (setq RTN (APPEND RTN (LIST (vlax-ename->vla-object EN)))))
)
)
(setq RTN (VL-REMOVE-IF
'(LAMBDA (X)
(IF (= "AcDbAttributeDefinition" (vla-get-ObjectName X))
(PROGN (vla-Delete X) T)
)
)
RTN
)
)
(FOREACH A RTN
(if
(OR (= "AcDbInsertBlock" (vla-get-ObjectName A))
(= "AcDbMInsertBlock" (vla-get-ObjectName A))
(= "AcDbBlockReference" (vla-get-ObjectName A))
)
(PROGN (setq RTN1 (APPEND RTN1 (GXL-EXPLODEBLOCK (vlax-vla-object->ename A)))) )
(PROGN (setq RTN1 (APPEND RTN1 (LIST A))))
)
)
RTN1
)
(DEFUN GXL-NUM-AX->LISPVALUE (V)
(COND
((= (TYPE V) 'variant) (GXL-NUM-AX->LISPVALUE (vlax-variant-value V)))
((= (TYPE V) 'safearray) (MAPCAR 'GXL-NUM-AX->LISPVALUE (safearray-value V)))
((= (TYPE V) 'LIST) (MAPCAR 'GXL-NUM-AX->LISPVALUE V))
(T V)
)
)
(DEFUN GXL-SEL-SSUNION (SSLIST)
(MAPCAR
'(LAMBDA (X / C)
(SETQ C -1)
(REPEAT (SSLENGTH X) (SSADD (SSNAME X (SETQ C (1+ C))) (CAR SSLIST)))
)
(CDR SSLIST)
)
(SSLENGTH (CAR SSLIST))
)
(DEFUN GXL-SEL-LIST->SS (LST / EN SS KK)
(setq SS (SSADD))
(setq KK 0)
(FOREACH EN LST (SSADD EN SS) (setq KK (1+ KK)))
SS
)
(DEFUN GXL-EXPLODE (SS / OBJ ERR SSRTN EN SS1 SELRTN)
(setq SELRTN (SSADD))
(COND
((= 'ENAME (TYPE SS))
(setq OBJ (vlax-ename->vla-object SS))
(COND
((OR (= "AcDbMInsertBlock" (vla-get-ObjectName OBJ))
(= "AcDbBlockReference" (vla-get-ObjectName OBJ))
)
(setq SSRTN (APPEND SSRTN (GXL-EXPLODEBLOCK OBJ)))
)
((OR (= "AcDb3dPolyline" (vla-get-ObjectName OBJ))
(= "AcDb2dPolyline" (vla-get-ObjectName OBJ))
(= "AcDbPolyline" (vla-get-ObjectName OBJ))
(= "AcDbModelerGeometry" (vla-get-ObjectName OBJ))
)
(setq ERR (VL-CATCH-ALL-APPLY 'vla-Explode (LIST OBJ)))
(if (VL-CATCH-ALL-ERROR-P ERR)
(PROGN (setq SSRTN (CONS OBJ SSRTN)))
(PROGN (setq SSRTN (APPEND SSRTN (GXL-NUM-AX->LISPVALUE ERR)))
(vla-Delete OBJ)
)
)
)
((OR (WCMATCH (STRCASE (vla-get-ObjectName OBJ)) "*DIMENSION")
(= "AcDbHatch" (vla-get-ObjectName OBJ))
)
(setq EN (ENTLAST))
(command "_.explode")
(command (vlax-vla-object->ename OBJ))
(GXL-SEL-SSUNION (LIST SELRTN (GXL-SEL-ENTNEXTALL EN)))
)
(T (setq SSRTN (CONS OBJ SSRTN)))
)
)
((= 'PICKSET (TYPE SS))
(setq SS (MAPCAR 'vlax-ename->vla-object (GXL-SEL-SS->LIST SS)))
(FOREACH OBJ SS
(COND
((OR (= "AcDbMInsertBlock" (vla-get-ObjectName OBJ))
(= "AcDbBlockReference" (vla-get-ObjectName OBJ))
)
(setq SSRTN (APPEND SSRTN (GXL-EXPLODEBLOCK OBJ)))
)
((OR (= "AcDb3dPolyline" (vla-get-ObjectName OBJ))
(= "AcDb2dPolyline" (vla-get-ObjectName OBJ))
(= "AcDbPolyline" (vla-get-ObjectName OBJ))
(= "AcDbModelerGeometry" (vla-get-ObjectName OBJ))
)
(setq ERR (VL-CATCH-ALL-APPLY 'vla-Explode (LIST OBJ)))
(if (VL-CATCH-ALL-ERROR-P ERR)
(PROGN (setq SSRTN (CONS OBJ SSRTN)))
(PROGN (setq SSRTN (APPEND SSRTN (GXL-NUM-AX->LISPVALUE ERR)))
(vla-Delete OBJ)
)
)
)
((OR (WCMATCH (STRCASE (vla-get-ObjectName OBJ)) "*DIMENSION")
(= "AcDbHatch" (vla-get-ObjectName OBJ))
)
(setq EN (ENTLAST))
(command "_.explode")
(command (vlax-vla-object->ename OBJ))
(GXL-SEL-SSUNION (LIST SELRTN (GXL-SEL-ENTNEXTALL EN)))
)
(T (setq SSRTN (CONS OBJ SSRTN)))
)
)
)
)
(GXL-SEL-SSUNION
(LIST SELRTN (GXL-SEL-LIST->SS (MAPCAR 'vlax-vla-object->ename SSRTN)))
)
SELRTN
)
(vl-ACAD-defun
(DEFUN C:SUP_EXP (/ SS FLAG)
(SETIERR)
(while (and (setq SS (SSGET)))
(GXL-SEL-MAPCAR
SS
'(lambda (X)
(if (= "INSERT" (GXL-DXF X 0))
(PROGN (GXL-SUPPEREXPLODEBLOCK X))
(PROGN (GXL-EXPLODE X))
)
)
)
)
(REERR)
(PRINC)
)
)
'C:SUP_EXP
(PRINC "\n超级炸弹,一炸到底 By Gu_xl 命令: Sup_exp")
(PRINC)