;;;CONVERT ( EXPLODE ) MINSERTS INTO SINGLE INSERTS
;;;05-05-2004 ADD XDATA & ATTRIBS ADDED
;;;05-07-2004 CLEANUP
;;;05-08-2004 PRESET DEFAULTS
;;;05-09-2004 FDI GLOBAL ENAME PASSING

(defun c:exmins (/ def ss en ed fe fl ml an ad al)

(setq def '(("CECOLOR" . "BYLAYER")
("CELTYPE" . "BYLAYER")
("THICKNESS" . 0)
("CELTSCALE" . 1)))

(foreach v def
(if (getvar (car v))
(setvar (car v) (cdr v))))
(if
(not
(and fdi_global_en
(= (type fdi_global_en) 'ENAME)
(entget fdi_global_en)
(= "INSERT" (cdr (assoc 0 (entget fdi_global_en))))
(setq en fdi_global_en)))
(progn
(while (or (not ss)
(> (sslength ss) 1))
(princ "\nSelect A MINSERT To Convert: ")
(setq ss (ssget (list (cons 0 "INSERT")))))
(setq en (ssname ss 0))))

(setq ed (entget en '("*")))

(setq fl '(0 1 2 6 7 8 10 11 39 40 41 42 43 44 45 50 51 62 66 67 70 71 72 73 74 210 -3))

(foreach g fl
(set (read (strcat "g" (itoa g)))
(cdr (assoc g ed)))
(and (assoc g ed)
(not (member g '(-3 44 45 70 71)))
(setq ml (cons (assoc g ed) ml))))

(if (not (assoc 67 ml))
(setq ml (cons (cons 67 0) ml)))

(if g-3 (setq ml (cons (assoc -3 ed) ml)))

(entmake (reverse ml))

(if (= (cdr (assoc 66 ed)) 1)
(progn
(setq an (entnext en))
(while (/= "SEQEND" (cdr (assoc 0 (entget an))))
(setq ad (entget an)
al nil)
(foreach g fl
(and (assoc g ad)
(setq al (cons (assoc g ad) al))))
(entmake (reverse al))
(setq an (entnext an)))
(entmake (list (cons 0 "SEQEND")
(cons 8 "0")))))

(entdel en)

(setvar "OSMODE" 0)
(setvar "CMDECHO" 0)
(setq fe (entlast))

(command "_.UCS" "_W")
(command "_.UCS" "_E" fe)

(cond ((and (> g71 1)
(> g70 1))
(command "_.ARRAY" fe "" "R" g71 g70 g45 g44))
((> g70 1)
(command "_.ARRAY" fe "" "R" 1 g70 g44))
((> g71 1)
(command "_.ARRAY" fe "" "R" g71 1 g45)))

(command "_.UCS" "_W")

(foreach g fl (set (read (strcat "g" (itoa g))) nil))

(setq fdi_global_en nil)

(prin1))

(c:exmins)

Advertisements