PDA

View Full Version : Simple LISP To Explode All MText?



AQucsaiJr
28th Oct 2009, 02:10 pm
I tried this, but it does not seem to work:


(defun c:ExplodeMtext ()
(command "._explode" (ssget "_X" '((0 . "MTEXT"))) "" )
(princ)
)


Anyone have a simple LISP that will explode all mtext in a drawing?

AQucsaiJr
28th Oct 2009, 02:34 pm
I got this to work... But it only explodes one occurrence of mtext...


(defun c:EXMT ()
(command "._explode" (ssget "X" (list (cons 0 "MTEXT"))) )
(princ)
)

I want to explode all mtext in one sweep.

Lee Mac
28th Oct 2009, 03:18 pm
Try something like this, untested:



(defun c:Explode_Mtext (/ i ss ent)
(if (setq i -1 ss (ssget "_X" '((0 . "MTEXT"))))
(while (setq ent (ssname ss (setq i (1+ i))))
(command "_.explode" ent)))
(princ))

AQucsaiJr
28th Oct 2009, 03:25 pm
Hey Lee;

That works great... I am getting an Unknown command "Explode_Mtext" error at the end, but it is working. I guess there is one too many () or "" somewhere.

AQucsaiJr
28th Oct 2009, 04:29 pm
So this is what I changed to fix the error at the end:

(defun c:EXMT (/ i ss ent)
(if (setq i -1 ss (ssget "_X" '((0 . "MTEXT"))))
(while (setq ent (ssname ss (setq i (1+ i))))
(command "_.explode" ent )))
(princ)
)

I changed the name only because I have a button that calls that name out and I am too lazy to change it... lol...

Thanks for the help Lee!

CarlB
28th Oct 2009, 06:36 pm
The first lisp you posted would have worked, if you first set "QAFLAGS" to 1.
Or you can set it in the outine, then set back to original.

QAFLAGS affects exploding a set in lisp, among other undocumented effects.

AQucsaiJr
28th Oct 2009, 06:44 pm
The first lisp you posted would have worked, if you first set "QAFLAGS" to 1.
Or you can set it in the outine, then set back to original.

QAFLAGS affects exploding a set in lisp, among other undocumented effects.

I have never used QAFLAGS... Could you show me the LISP the way you are talking about with the QAFLAGS?

CarlB
28th Oct 2009, 06:50 pm
Sure...

(defun c:ExplodeMtext ()
(setq UsrQA (getvar "QAFLAGS"))
(setvar "QAFLAGS" 1)
(command "._explode" (ssget "_X" '((0 . "MTEXT"))) "" )
(setvar "QAFLAGS" UsrQA)
(princ)
)

AQucsaiJr
28th Oct 2009, 07:00 pm
Ok... I see... Thanks CarlB