; MEXPLODE.LSP : X, Y ºñÀ²ÀÌ ´Ù¸¥ BLOCKÀ» EXPLODEÇÏ´Â ÇÁ·Î±×·¥ ; ÀÛ¼ºÀÏ : 1994. 10. 2. ; ÀÛ¼ºÀÚ : ÃÖ¹®¼± ; Àü¿ªº¯¼ö ; #MODEL : ½Ã½ºÅÛ º¯¼ö°ªÀ» Àӽ÷ΠÀúÀåÇÒ ¸®½ºÆ® ; #SFLAG : X, Y, Z ½ºÄÉÀÏÀÌ ¸ðµÎ °°À¸¸é T, ¾Æ´Ï¸é nil (setq #MODEL nil) (setq #SFLAG nil) ; »ç¿ëÇÒ ½Ã½ºÅÛ º¯¼öÀÇ ÇöÀç°ªÀ» ´ëÇǽÃŲ´Ù. ; ÇØ´ç ½Ã½ºÅÛ º¯¼öÀÇ °ªÀ» ¼³Á¤ÇÑ´Ù. (defun push-mode () (setq #MODEL (list (getvar "BLIPMODE") (getvar "CMDECHO") (getvar "EXPERT") (getvar "OSMODE") ) ) (setvar "BLIPMODE" 0) (setvar "CMDECHO" 0) (setvar "EXPERT" 1) (setvar "OSMODE" 0) ) ; ´ëÇǽÃÄѵР½Ã½ºÅÛ º¯¼öÀÇ °ªÀ» º¹±¸½ÃŲ´Ù. (defun pop-mode () (setvar "BLIPMODE" (car #MODEL)) (setvar "CMDECHO" (cadr #MODEL)) (setvar "EXPERT" (caddr #MODEL)) (setvar "OSMODE" (cadddr #MODEL)) (princ) ) ; »ç¿ëÀÚ Á¤ÀÇ ¿¡·¯ ó¸® ÇÔ¼ö ; ½Ã½ºÅÛ º¯¼öÀÇ °ªÀ» º¹±¸½ÃŲ´Ù. (defun *ERROR* (msg) (if (/= msg "Function cancelled") (if (= msg "quit / exit abort") (princ) (princ (strcat "\nError: " msg "\n")) ) (princ) ) (redraw) (pop-mode) ) ; ÁÖ¾îÁø ¿£Æ¼Æ¼ ÀÌÈÄ¿¡ »ý¼ºµÈ ¸ðµç ¿£Æ¼Æ¼µéÀ» ÇϳªÀÇ selection-setÀ¸·Î ¸¸µç´Ù. (defun pick-entity (el / ss) ; »õ·Î¿î selection-setÀ» ¸¸µç´Ù. (setq ss (ssadd)) ; ´õ ÀÌ»ó ¿£Æ¼Æ¼°¡ ¾øÀ» ¶§±îÁö ¼öÇà (while (setq el (entnext el)) ; selection-set¿¡ ¿£Æ¼Æ¼¸¦ Ãß°¡ (setq ss (ssadd el ss)) ) ; °á°ú selection-setÀ» ¹Ýȯ ss ) ; ARRAY (defun multi-array (ss cc rc cs rs ang / oang) (setq oang (getvar "SNAPANG")) (setvar "SNAPANG" ang) (setq ang (/ (* ang 180.0) PI)) (if (and (< 1 cc) (< 1 rc)) (command "ARRAY" ss "" "R" rc cc rs cs) (if (< 1 cc) (command "ARRAY" ss "" "R" "1" cc cs) (if (< 1 rc) (command "ARRAY" ss "" "R" rc "1" rs) ) ) ) (setvar "SNAPANG" oang) ) ; ÁÂÇ¥º¯È¯À» ¼öÇàÇÑ´Ù. (defun calc-xpoint (po sc ang bp / rp) (setq po (mapcar '* po sc)) (if (= ang 0.0) (setq rp po) (setq rp (list (- (* (car po) (cos ang)) (* (cadr po) (sin ang))) (+ (* (car po) (sin ang)) (* (cadr po) (cos ang))) ) ) ) (mapcar '+ bp rp) ) ; Á¡ µ¥ÀÌŸ¸¦ º¯°æ (defun subst-point (num sc ang bp el) (subst (cons num (calc-xpoint (cdr (assoc num el)) sc ang bp)) (assoc num el) el) ) ; Á¡ÀÌ ÇÑ°³ÀÎ ¿£Æ¼Æ¼¿¡ ´ëÇÑ Ã³¸® (defun point1-exp (sc ang bp el) (subst-point 10 sc ang bp el) ) ; Á¡ÀÌ µÎ°³ÀÎ ¿£Æ¼Æ¼¿¡ ´ëÇÑ Ã³¸® (defun point2-exp (sc ang bp el) (setq el (subst-point 10 sc ang bp el)) (setq el (subst-point 11 sc ang bp el)) ) ; Á¡ÀÌ ³×°³ÀÎ ¿£Æ¼Æ¼¿¡ ´ëÇÑ Ã³¸® (defun point4-exp (sc ang bp el) (setq el (subst-point 10 sc ang bp el)) (setq el (subst-point 11 sc ang bp el)) (setq el (subst-point 12 sc ang bp el)) (setq el (subst-point 13 sc ang bp el)) ) ; ARC¿¡ ´ëÇÑ Ã³¸® (defun arc-exp (sc ang bp el) (setq el (subst-point 10 sc ang bp el)) (setq el (subst (cons 40 (* (cdr (assoc 40 el)) (car sc))) (assoc 40 el) el)) (setq el (subst (cons 50 (+ (cdr (assoc 50 el)) ang)) (assoc 50 el) el)) (setq el (subst (cons 51 (+ (cdr (assoc 51 el)) ang)) (assoc 51 el) el)) ) ; CIRCLE¿¡ ´ëÇÑ Ã³¸® (defun circle-exp (sc ang bp el) (setq el (subst-point 10 sc ang bp el)) (setq el (subst (cons 40 (* (cdr (assoc 40 el)) (car sc))) (assoc 40 el) el)) ) ; ºí·°À» ºÐ¸® (defun insert-exp (sc ang bp el) (setq el (subst-point 10 sc ang bp el)) (setq el (subst (cons 41 (* (cdr (assoc 41 el)) (car sc))) (assoc 41 el) el)) (setq el (subst (cons 42 (* (cdr (assoc 42 el)) (cadr sc))) (assoc 42 el) el)) (setq el (subst (cons 43 (* (cdr (assoc 43 el)) (caddr sc))) (assoc 43 el) el)) (setq el (subst (cons 50 (+ (cdr (assoc 50 el)) ang)) (assoc 50 el) el)) ) ; °¢ ºí·°À» ¿£Æ¼Æ¼·Î ºÐÇØ (defun exp-block (en sc ang bp cl / dflag el etype flag) (setq dflag T) (while en (setq el (entget en)) (setq etype (cdr (assoc 0 el))) (setq flag T) (cond ((= etype "3DFACE") (setq el (point4-exp sc ang bp el))) ((= etype "INSERT") (setq el (insert-exp sc ang bp el))) ((= etype "LINE") (setq el (point2-exp sc ang bp el))) ((= etype "POINT") (setq el (point1-exp sc ang bp el))) ((= etype "POLYLINE") T) ((= etype "SEQEND") T) ((= etype "SOLID") (setq el (point4-exp sc ang bp el))) ((= etype "TRACE") (setq el (point4-exp sc ang bp el))) ((= etype "VERTEX") (setq el (point1-exp sc ang bp el))) (T (if (and #SFLAG (or (= etype "ARC") (= etype "CIRCLE"))) (if (= etype "ARC") (setq el (arc-exp sc ang bp el)) (setq el (circle-exp sc ang bp el)) ) (progn ; EXPLODE ÇÒ ¼ö ¾ø´Â ¿£Æ¼Æ¼ÀÎ °æ¿ì (princ (strcat "\nError! Unable to explode " etype " entity")) ; »èÁ¦ flag°ú »ý¼º flag À» nil·Î ¼³Á¤ (setq dflag nil flag nil) ) ) ) ) ; °¢°¢ÀÇ ¿£Æ¼Æ¼¸¦ º¯ÇüµÈ ÇüÅ·ΠÀç »ý¼ºÇÑ´Ù. (if flag (entmake (subst (cons 8 cl) (assoc 8 el) el))) (setq en (entnext en)) ) dflag ) ; ºí·°¿¡ ´ëÇÑ EXPLODE ¼öÇà (defun exp-insert (en / le el sc cnt rcnt clyr bp rz bn cspc rspc ent dflag ss) (setq le (entlast)) (setq el (entget en)) ; ºí·°ÀÇ X, Y, Z scale°ú ¿­, ÇàÀÇ ¼ö, ·¹À̾î¸íÀ» ±¸ÇÑ´Ù. (setq sc (list (cdr (assoc 41 el)) (cdr (assoc 42 el)) (cdr (assoc 43 el))) ccnt (cdr (assoc 70 el)) rcnt (cdr (assoc 71 el)) clyr (cdr (assoc 8 el)) ) (if (and (and (= (car sc) (cadr sc)) (= (cadr sc) (caddr sc))) (and (= ccnt 0) (= rcnt 0)) ) ; X, Y, Z scaleÀÌ ¸ðµÎ °°°í, MINSERT µÈ °ÍÀÌ ¾Æ´Ï¸é ¼öÇà (command "EXPLODE" en) (progn (if (or (/= ccnt 0) (/= rcnt 0)) (princ "\nWarning! Cannot explode a MINSERTed block"); ) (if (or (/= (abs (car sc)) (abs (cadr sc))) (/= (abs (cadr sc)) (abs (caddr sc)))) (progn (princ "\nWarning! X, Y, and Z scale factors must be equal.") (setq #SFLAG nil) ) (setq #SFLAG T) ) ; ºí·°ÀÇ »ðÀÔÁ¡, ȸÀü°¢, ºí·°¸í, ¿­, ÇàÀÇ °£°ÝÀ» ±¸ÇÑ´Ù. (setq bp (cdr (assoc 10 el)) rz (cdr (assoc 50 el)) bn (cdr (assoc 2 el)) cspc (cdr (assoc 44 el)) rspc (cdr (assoc 45 el)) ) ; ºí·°ÀÇ ½ÃÀÛ ¿£Æ¼Æ¼ÀÇ À̸§À» ±¸ÇÑ´Ù. (setq ent (cdr (assoc -2 (tblsearch "BLOCK" bn)))) ; ºí·°À» °¢°¢ÀÇ ¿£Æ¼Æ¼·Î ºÐÇØÇÑ´Ù. (setq dflag (exp-block ent sc rz bp clyr)) ; dflagÀÌ TÀ̸é EXPLODE µÇ±âÀü ¿£Æ¼Æ¼¸¦ Áö¿î´Ù. (if dflag (entdel en)) ; MINSERTµÈ ºí·°À̸é EXPLODE µÈ ¿£Æ¼Æ¼µéÀ» ; ÀÌ¿ëÇÏ¿© ARRAY ÀÛ¾÷À» ¼öÇàÇÑ´Ù. (if (or (/= ccnt 0) (/= rcnt 0)) (progn (setq ss (pick-entity le)) (if ss (multi-array ss ccnt rcnt cspc rspc rz)) ) ) ) ) ) ; ¿£Æ¼Æ¼ Á¾·ù¿¡ µû¸¥ EXPLODE ¼öÇà (defun ent-explode (en / etype) (setq etype (cdr (assoc 0 (entget en)))) (cond ((= etype "DIMENSION") (command "EXPLODE" en)) ((= etype "INSERT") (exp-insert en)) ((= etype "POLYLINE") (command "EXPLODE" en)) (T (princ "\nNot a block reference, polyline, mesh, or dimension.")) ) ) ; »õ·Î¿î EXPLODE °úÁ¤ (defun max-explode (ss / sl el in) (setq sl (sslength ss)) ; EXPLODEµÈ ¸ðµç ¿£Æ¼Æ¼µéÀ» ÇϳªÀÇ selection-setÀ¸·Î ; ¸¸µé±â À§ÇØ ¸¶Áö¸· ¿£Æ¼Æ¼ÀÇ À̸§À» ¾Ë¾ÆµÐ´Ù. (setq el (entlast)) ; ¿£Æ¼Æ¼ ¹øÈ£¸¦ 0À¸·Î ¼³Á¤ (setq in 0) (while (< in sl) (setq en (ssname ss in)) ; ¿£Æ¼Æ¼ Á¾·ù¿¡ µû¸¥ EXPLODE ¼öÇà (ent-explode en) (setq in (1+ in)) ) ; EXPLODEµÈ ¸ðµç ¿£Æ¼Æ¼µéÀ» ÇϳªÀÇ selection-setÀ¸·Î ¸¸µç´Ù. (setq ss (pick-entity el)) ; ¸¸µé¾îÁø selection-setÀ» previous selection-setÀ¸·Î ¸¸µç´Ù. (command "SELECT" ss "") ) ; Àüü ÇÁ·Î±×·¥À» C:MEXPLODE ÇÔ¼ö·Î Á¤ÀÇÇÑ´Ù. (defun C:MEXPLODE ( / ss) (push-mode) ; EXPLODE ÇÒ ´ë»óµéÀÌ ¼±ÅÃµÇ¸é »õ·Î¿î EXPLODE °úÁ¤ ¼öÇà (if (setq ss (ssget)) (max-explode ss) ) (pop-mode) )