Author Topic: lisp not loading at startup  (Read 5701 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
lisp not loading at startup
« on: July 07, 2009, 04:12:16 PM »
hello experts

would anyone know why this code wouldnt work at startup?
or maybe have a better way to explode all mtext in a dwg  upon opening.

this is placed in my acaddoc.lsp it shows as it being loaded but doesnt do what it supposed to, which is explode all mtext when it loads

Code: [Select]
(defun s::startup ()
(if ss (ssget "x" '((0 . "mtext")))
 (progn
(setvar "qaflags" 1)
(command ".explode" "p" "")
(setvar "qaflags" 0)
)
)
  (princ)
)
thanks for any and all help

ronjonp

  • Needs a day job
  • Posts: 7526
Re: lisp not loading at startup
« Reply #1 on: July 07, 2009, 04:16:49 PM »
Give this a try:

Code: [Select]
(defun c:kaboomkaboom? (/ ss)
  (if (setq ss (ssget "x" '((0 . "mtext"))))
    (progn (setvar "qaflags" 1) (command ".explode" ss "") (setvar "qaflags" 0))
  )
  (princ)
)
;;Need to call the lisp
(c:kaboomkaboom?)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: lisp not loading at startup
« Reply #2 on: July 07, 2009, 04:18:09 PM »
Quote from: andrew_nao link=topic=29400.msg349538#msg349538 date=1246997536

[code
(defun s::startup ()
(if ss (ssget "x" '((0 . "mtext")))
 (progn
(setvar "qaflags" 1)
(command ".explode" "p" "")
(setvar "qaflags" 0)
)
)
  (princ)
)
[/code]

Could be you missed (Setq...

andrew_nao

  • Guest
Re: lisp not loading at startup
« Reply #3 on: July 07, 2009, 04:28:17 PM »
@ ron, it doesnt work that way either i tried that and was suggested to put it in s::startup

@ lee no setq shouldnt be needed. it works when loaded manually
so the there is nothing wrong with the code. it just wont load at startup

T.Willey

  • Needs a day job
  • Posts: 5251
Re: lisp not loading at startup
« Reply #4 on: July 07, 2009, 04:31:18 PM »
@ lee no setq shouldnt be needed. it works when loaded manually
so the there is nothing wrong with the code. it just wont load at startup

Of course if loads, as the ' if ' statement is a valid one, but the code won't do what you think it should be.  If you run the code without a global variable ' ss ' then the code will try and explode the previous selection set, but if ' ss ' is defined, it will only select all mtext entities, then end the code.  Lee makes a good point.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: lisp not loading at startup
« Reply #5 on: July 07, 2009, 04:49:47 PM »
@ ron, it doesnt work that way either i tried that and was suggested to put it in s::startup

@ lee no setq shouldnt be needed. it works when loaded manually
so the there is nothing wrong with the code. it just wont load at startup


Works fine here?  :?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lisp not loading at startup
« Reply #6 on: July 08, 2009, 08:30:34 AM »
I'm with Tim.
Code: [Select]
(defun s::startup ()
  (if ss
    (ssget "x" '((0 . "mtext")))
    (progn
      (setvar "qaflags" 1)
      (command ".explode" "p" "")
      (setvar "qaflags" 0)
    )
  )
  (princ)
)

The code does this:
Quote
Check for variable ss
If ss exist get a selection set of ALL mtext in the drawing & exit
if ss is nil then explode the Previous Object(s)

The problem with Ron's version is that ssget ALL mtext in the drawing & then execute a COMMAND witch
I think will not work unless you feed it mtext in the current space.
Off to test this...  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lisp not loading at startup
« Reply #7 on: July 08, 2009, 08:34:51 AM »
In my test the explode does work for mtext in the current space & ignores mtext not in current space.
Tested in ACAD2000
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

andrew_nao

  • Guest
Re: lisp not loading at startup
« Reply #8 on: July 08, 2009, 08:56:16 AM »
ok so even if i still change it to what lee suggested, i still cant get this to execute when a dwg is opened.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: lisp not loading at startup
« Reply #9 on: July 08, 2009, 08:59:58 AM »
what file are you putting the code in?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

ronjonp

  • Needs a day job
  • Posts: 7526
Re: lisp not loading at startup
« Reply #10 on: July 08, 2009, 12:31:13 PM »
...

The problem with Ron's version is that ssget ALL mtext in the drawing & then execute a COMMAND witch
I think will not work unless you feed it mtext in the current space.
Off to test this...  8-)

Picky picky  :-P

Code: [Select]
(defun c:kaboomkaboom? (/ ss n)
  (vl-load-com)
  (setq n -1)
  (if (setq ss (ssget "_x" '((0 . "MTEXT"))))
    (setq n -1)
    (while (setq e (ssname ss (setq n (1+ n))))
      (vl-catch-all-apply 'vla-explode (list (vlax-ename->vla-object e)))
    )
  )
  (princ)
)
;;Need to call the lisp
(c:kaboomkaboom?)

Apparently vla-explode does not work with MTEXT.....I give up  :-D
« Last Edit: July 08, 2009, 12:34:30 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: lisp not loading at startup
« Reply #11 on: July 08, 2009, 01:43:55 PM »
Apparently vla-explode does not work with MTEXT.....I give up  :-D

Yeah, its pretty annoying  ;-)

Crank

  • Water Moccasin
  • Posts: 1503
Re: lisp not loading at startup
« Reply #12 on: July 09, 2009, 06:21:32 AM »
With every new release the behaviour of existing commands may change. So when certain commands (for example EXPLODE) are issued in the Lisp routine, they may not behave as in previous version.  The workaround is to add (initcommandversion 2) before the command is called. You can try this:
Code: [Select]
(defun s::startup ()
(if (ssget "X" '((0 . "MTEXT")))
(progn
; (setvar "qaflags" 1)
[color=red](initcommandversion 2)[/color]
(command "._explode" "P" "")
; (setvar "qaflags" 0)
)
)
(princ)
)

BTW... I wonder why you are turning off the grips? If you start a new drawing it seems to me that nothing is selected...
Vault Professional 2023     +     AEC Collection

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lisp not loading at startup
« Reply #13 on: July 09, 2009, 08:52:50 AM »
Crank,
What version of ACAD was initcommandversion introduced?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: lisp not loading at startup
« Reply #14 on: July 09, 2009, 09:01:57 AM »
Crank,
What version of ACAD was initcommandversion introduced?


I believe it was introduced in AutoCAD 2009
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie