Is it possible to use the explode command in a lisp. My issue is that we export CIVIL3d to Autocad and we have to explode the spot labels twice to have them go from a block reference to Mtext then finally to text. It would be great to add this to a routine I have in the tool palette.
Thanks
Allan
Something like this perhaps.
(defun c:test (/ ENT HND I OBJ SS SS1) (setq ss (ssadd)) (setq obj (entlast)) (if (setq ss1 (ssget "_+.:E:S:L" '((0 . "INSERT")))) (progn (command "_.explode" ss1) (while (setq obj (entnext obj)) (ssadd obj ss) ) (repeat (setq i (sslength ss)) (setq hnd (ssname ss (setq i (1- i))) ent (entget hnd) ) (if (= (cdr (assoc 0 ent)) "MTEXT") (command "_.explode" hnd) ) ) ) ) (princ) )
HTH
Henrique
Try the following function:
(defun explode-to-end ( ent / enl tmp ) (setq enl (entlast)) (while (setq tmp (entnext enl)) (setq enl tmp)) (explode ent) (while (setq enl (entnext enl)) (explode-to-end enl)) (princ) ) (defun explode ( ent / cmd rtn qaf ) (if (not (member (cdr (assoc 0 (entget ent))) '( "ARC" "ATTDEF" "CIRCLE" "ELLIPSE" "LINE" "POINT" "RAY" "SPLINE" "TEXT" "XLINE" ) ) ) (progn (setq qaf (getvar 'qaflags) cmd (getvar 'cmdecho) ) (setvar 'qaflags 1) (setvar 'cmdecho 0) (setq rtn (vl-cmdf "_.explode" ent "")) (setvar 'cmdecho cmd) (setvar 'qaflags qaf) rtn ) ) )
Call the function with the entity name of the object to be exploded, e.g.:
(defun c:test ( / ent ) (if (setq ent (car (entsel))) (explode-to-end ent) ) (princ) )
Thanksyou but it will only work for me on a single entity, can it be done to multiple?
Thanks
Allan
To do multiple text elements change the currest test function to this function from Lee Mac's site
and change (print x) to (explode-to-end e)
(defun c:test1 ( / e i n s x ) (if (setq s (ssget)) (progn (setq i 0 n (sslength s) ) (while (< i n) (setq e (ssname s i) x (cdr (assoc 0 (entget e))) i (1+ i) ) (explode-to-end e) ) ) ) (princ) )
Thanks for the reply, I am new to lsip so bear with me.
I tried to rearrange this but I still cant get it to work?
Any help is appreciated, thakyou all for your time in the mean time.
Cheers
Allan
(defun explode-to-end ( ent / enl tmp ) (setq enl (entlast)) (while (setq tmp (entnext enl)) (setq enl tmp)) (explode ent) (while (setq enl (entnext enl)) (explode-to-end enl)) (princ) ) (defun explode ( ent / cmd rtn qaf ) (if (not (member (cdr (assoc 0 (entget ent))) '( "ARC" "ATTDEF" "CIRCLE" "ELLIPSE" "LINE" "POINT" "RAY" "SPLINE" "TEXT" "XLINE" ) ) ) (progn (setq qaf (getvar 'qaflags) cmd (getvar 'cmdecho) ) (setvar 'qaflags 1) (setvar 'cmdecho 0) (setq rtn (vl-cmdf "_.explode" ent "")) (setvar 'cmdecho cmd) (setvar 'qaflags qaf) rtn ) ) ) (defun c:test ( / e i n s x ) (if (setq s (ssget)) (progn (setq i 0 n (sslength s) ) (while (< i n) (setq e (ssname s i) x (entget e) i (1+ i) ) (explode-to-end e) ) ) ) (princ) )
Download the attached lisp file.
Command name : TEST
Excellent to hear allanbsteven