CAD PANACEA HAS MOVED TO http://cadpanacea.com
18 August 2008
S::STARTUP Function          
In the previous post about Startup Lisp Functions, the special (S::STARTUP) function was mentioned. Startup lisp code is loaded before the drawing is initialized, but you cannot call the (COMMAND) function until after the drawing is initialized. The solution is to place your (COMMAND) calls inside the (S::STARTUP) function. For example, if you want to reset the scale list and purge out regapps each time a drawing is opened, you could use something like this:
(defun-q mystartup ()
(command "._purge" "_R" "*" "_N")
(command "._-scalelistedit" "_R" "_Y" "_E")
)
(setq S::STARTUP (append S::STARTUP mystartup))

Notice that we did not directly define (S::STARTUP). Because this function can be defined in other places, it is best to append to it rather than overwrite it. Use (defun-q) to create a function defined as a list, so it can be appended. To finish the example from the previous post...

;;; acaddoc.lsp
(load "mylisp")
(load "another_lisp")
(load "\\\\server\\share\\a_lisp_and_specify_the_path")
(setvar "blipmode" 0)
(setvar "highlight" 1)
(defun-q mystartup ()
(command "._purge" "_R" "*" "_N")
(command "-scalelistedit" "_R" "_Y" "_E")
)
(setq S::STARTUP (append S::STARTUP mystartup))
;;; end acaddoc.lsp

Labels: , ,


PermaLink       Posted 8/18/2008 08:10:00 PM     
4 COMMENTS!


Comment from: Blogger mjs9199
Date: August 19, 2008 at 7:10:00 AM CDT  

so if my acad.lsp and custom MNL file only use functions like autoload, load, princ, prompt and setenv, then am I correct in saying that I don't need to use the S::STARTUP concept?


Comment from: Blogger R.K. McSwain
Date: August 19, 2008 at 12:22:00 PM CDT  

Only (command) functions need to go in the (S::STARTUP) function.

I have seen instances where certain (command) functions work even if they are not defined in (S::STARTUP), but that is not guaranteed.


Comment from: Anonymous Anonymous
Date: September 29, 2008 at 7:14:00 AM CDT  

interesting procedure, i've used commands such as


;creates thaws and turns on defpoints

(if (tblsearch "LAYER" "defpoints");;test if layer exists
(command "-layer" "thaw" "defpoints" "on" "defpoints" "") ;do this if exists
(command "-layer" "n" "defpoints" "c" "63" "defpoints" "");do this if not
)

which are quite lengthy with out it erroring... maybe i'm missing something?? Or your way is cleaner or better?
-Hammer


Comment from: Anonymous Anonymous
Date: September 29, 2008 at 7:20:00 AM CDT  

To quote the AutoCAD developers guide...

"the command function, ... is not guaranteed to work until after a drawing is initialized."

So, it *may* work, but no promises.

Post a comment