Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
bodhran
Posts: 69
Registered: ‎10-14-2010
Message 1 of 7 (756 Views)
Accepted Solution

script to explode mtext

756 Views, 6 Replies
05-18-2011 02:49 PM

 

Hi guys,

 

I'm trying to explode mtext in a number of our dwgs, here's whaat i've come up with.

 

EXPLODE
(ssget "X" '((0 . "MTEXT")))

it works fine if i run it at the command prompt but not if i run it via script?

 

What am i not getting??

 

Regards,

 

B

For some reason the explode command doesn't accept the entire selection set.  I tried your code and with the exception of a missing close parenthesis it seemed like it should have worked.  I fixed that but it only exploded 1 of the mtext objects in the sslist.  This code adds them to an entitylist and then explodes each one...

 

(setq mt (ssget "X" '((0 . "MTEXT"))))
(setq ctr 0)
(while (setq cent (ssname mt ctr))
 (Setq objlist (append (list cent) objlist))
 (setq ctr (1+ ctr))
);while
(foreach mtextobj objlist
  (command ".explode" mtextobj)
);foreach
(setq mt nil
      ctr nil
      objlist nil)


bodhran wrote:
(setq mt (ssget "X" '((0 . "MTEXT"))) <-- Missing ) here.

BTW.. you can see that your code works if you run this line (setq mt (ssget "x" '((0 . "MTEXT")))) and then run (sslength mt)  That should return the count of objects in your mt selection set.

 

BTW #2.. If you also do (setq mt (ssget "x" '((0 . "MTEXT")))) and then (command "move" mt "")  see what happens...

*Expert Elite*
scot-65
Posts: 2,195
Registered: ‎12-11-2003
Message 2 of 7 (754 Views)

Re: script to explode mtext

05-18-2011 03:24 PM in reply to: bodhran

A few of the LISP expressions are not allowed while inside a command.

Try restructuring:

(setq s (ssget...

(command "EXPLODE" s "")

(setq s nil)

 

[untested]

 

???

Scot-65
Dyslexia is a permanent physical disability that cannot be seen.
Introverts is proof that there is indeed intelligent life on this planet.
Valued Contributor
bodhran
Posts: 69
Registered: ‎10-14-2010
Message 3 of 7 (752 Views)

Re: script to explode mtext

05-18-2011 03:46 PM in reply to: scot-65

Hi scot-65,

 

well i've tried:

(setq mt (ssget "X" '((0 . "MTEXT")))
(command "EXPLODE" mt "")
(setq mt nil)

but it doeesn't work, i'm a novice at the ssget thing so it maybe something i'm just not getting right

 

B

Valued Mentor
Shneuph
Posts: 353
Registered: ‎11-26-2007
Message 4 of 7 (748 Views)

Re: script to explode mtext

05-18-2011 04:29 PM in reply to: bodhran

For some reason the explode command doesn't accept the entire selection set.  I tried your code and with the exception of a missing close parenthesis it seemed like it should have worked.  I fixed that but it only exploded 1 of the mtext objects in the sslist.  This code adds them to an entitylist and then explodes each one...

 

(setq mt (ssget "X" '((0 . "MTEXT"))))
(setq ctr 0)
(while (setq cent (ssname mt ctr))
 (Setq objlist (append (list cent) objlist))
 (setq ctr (1+ ctr))
);while
(foreach mtextobj objlist
  (command ".explode" mtextobj)
);foreach
(setq mt nil
      ctr nil
      objlist nil)


bodhran wrote:
(setq mt (ssget "X" '((0 . "MTEXT"))) <-- Missing ) here.

BTW.. you can see that your code works if you run this line (setq mt (ssget "x" '((0 . "MTEXT")))) and then run (sslength mt)  That should return the count of objects in your mt selection set.

 

BTW #2.. If you also do (setq mt (ssget "x" '((0 . "MTEXT")))) and then (command "move" mt "")  see what happens...

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Valued Contributor
bodhran
Posts: 69
Registered: ‎10-14-2010
Message 5 of 7 (742 Views)

Re: script to explode mtext

05-18-2011 04:32 PM in reply to: Shneuph

 

**** parenthesis!!

 

Thanks that's exxcellent!! work a treat!!

 

B

*Expert Elite*
Kent1Cooper
Posts: 5,616
Registered: ‎09-13-2004
Message 6 of 7 (724 Views)

Re: script to explode mtext

05-19-2011 04:21 AM in reply to: Shneuph

Shneuph wrote:

For some reason the explode command doesn't accept the entire selection set.  ...it only exploded 1 of the mtext objects in the sslist.  ....


This has come up several times before -- search the discussion group for Explode and the mysterious QAFLAGS System Variable.

Kent Cooper
New Member
peszel
Posts: 1
Registered: ‎05-26-2011
Message 7 of 7 (682 Views)

Re: script to explode mtext

05-26-2011 03:11 AM in reply to: bodhran

Try this:

 

(defun C:MTXEX ( / ss )
  (setvar "QAFLAGS" 1)
  (setq ss (ssget "x" (list (cons 0 "MTEXT"))))
    (if ss
      (command "._EXPLODE" ss "")
    )
  (setvar "QAFLAGS" 0)
)

(princ "\n** Type MTXEX to invoke **")
(princ)

 

peszel

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.