AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Would you like a different version?
Minserts to Inserts and visa versa.

Peter Jamtgaard

;CODING STARTS HERE
;Minsert to Insert
(defun C:MINTOIN (/ B CNT BELST BENAM ELST ENAM SSET)
(setq SSET (ssget (list (cons 0 "INSERT")))
CNT 0
)
(if SSET
(progn
(repeat (sslength SSET)
(setq ENAM (ssname SSET CNT)
ELST (entget ENAM)

)
(if (= (cdr (assoc 100 (reverse ELST))) "AcDbMInsertBlock")
(progn
(setq ELST (subst (cons 70 0)(assoc 70 ELST) ELST)
ELST (subst (cons 71 0)(assoc 71 ELST) ELST)
ELST (reverse (subst (cons 100 "AcDbBlockReference")(assoc 100 (reverse ELST)) (reverse ELST)))
BENAM ENAM
CNT (1+ CNT)
)
(entmake (cdr ELST))
(setq B 0)
(if (= (cdr (assoc 66 ELST)) 1)
(while B
(setq BENAM (entnext BENAM)
BELST (entget BENAM)
)
(entmake (cdr BELST))
(if (= (cdr (assoc 0 BELST)) "SEQEND")(setq B nil))
)
)
(entdel ENAM)
)
)
)
)
)
(prin1)
)
;CODING ENDS HERE
----------------------------------

;CODING STARTS HERE
;Insert to Minsert
(defun C:INTOMIN (/ B CNT BELST BENAM ELST ENAM SSET)
(setq SSET (ssget (list (cons 0 "INSERT")))
CNT 0
)
(if SSET
(progn
(repeat (sslength SSET)
(setq ENAM (ssname SSET CNT)
ELST (entget ENAM)

)
(if (= (cdr (assoc 100 (reverse ELST))) "AcDbBlockReference")
(progn
(setq ELST (subst (cons 70 2)(assoc 70 ELST) ELST)
ELST (subst (cons 71 2)(assoc 71 ELST) ELST)
ELST (reverse (subst (cons 100 "AcDbMInsertBlock")(assoc 100 (reverse ELST)) (reverse ELST)))
BENAM ENAM
CNT (1+ CNT)
)
(entmake (cdr ELST))
(setq B 0)
(if (= (cdr (assoc 66 ELST)) 1)
(while B
(setq BENAM (entnext BENAM)
BELST (entget BENAM)
)
(entmake (cdr BELST))
(if (= (cdr (assoc 0 BELST)) "SEQEND")(setq B nil))
)
)
(entdel ENAM)
)
)
)
)
)
(prin1)
)
;CODING ENDS HERE

The AutoLisp/Visual Lisp/VBA Resource Website

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website