Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp Loading problem

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
CSM_MAI
575 Views, 9 Replies

Lisp Loading problem

Hello, I have a lisp that loads to each of the User's machines when AutoCAD opens a new drwaing.  The lisp has all of our custom commands and prompts etc. and also sets environment variables. I recently added a new portion (4) to the lisp that will load another lisp when the drawing starts up. For some reason, when the global,lsp loads and it loads the external lisp, it will not recognize any of the other commands in the global.lsp.  When I put the ";" in front of the "(load "external.lsp") and save, all of the other commands work fine, and of course it does not load the external.lsp. Is it not recognizing the global lisp after I load the other lisp. Below is a generic version of what I have. 1, 2, and 3 are all custom commands we use in the office. 4 is another lisp we use. It's a pretty long lisp, so instead of putting it in the global.lsp, I made it a separate lisp that loads with with the lisp files in the customization file. All of these commands work fine until I add the (load "external.lsp") in the routine. Then it will not recognize the other commands. Any info on this would be much appreciated.  Thanks.

 

 

Global.lsp

;;;(1)

(defun c: blah blah ()

( code for the lisp)

(princ)

)

 

;;;(2)

(defun c: blah blah ()

( code for the lisp)

(princ)

)

 

;;;(3)

(defun c: blah blah ()

( code for the lisp)

(princ)

)

 

;;;(4)

(load "external.lsp")            <when i put a semicolon in front of this, all of the other command start working again.

(setvar "blah blah")

(command "blah")

(command "blah")

(princ)

9 REPLIES 9
Message 2 of 10
Kent1Cooper
in reply to: CSM_MAI

I certainly have some (load) functions in my acaddoc.lsp, and they don't prevent subsequent functions from running.  But a couple of possibilities occur to me:

 

Does external.lsp contain a (quit) or (exit) function?

 

Can you put the loading of external.lsp last, or does it set up certain things that are needed by what follows it?

Kent Cooper, AIA
Message 3 of 10
CSM_MAI
in reply to: CSM_MAI

The external lisp does have an exit function. It looks for a support file path, and if it finds it, it exits rather than continuing the rest of the lisp. I've tried adding the (unload "external.lsp") after load, and also tried to add  (load "global.lsp") back into the routine in hopes it will work that way without any luck.

Message 4 of 10
stevor
in reply to: CSM_MAI

The statement: (load "external.lsp") does not include the path to the 'external.lsp.' Research 'paths' for the autocad.
S
Message 5 of 10
Kent1Cooper
in reply to: CSM_MAI


@CSM_MAI wrote:

The external lisp does have an exit function. It looks for a support file path, and if it finds it, it exits rather than continuing the rest of the lisp. ....


Can you revise external.lsp so that it doesn't exit, but rather just doesn't continue with the rest, if it finds that path?

 

(if (...it finds the support path...)

  (prompt "\nPath found."); 'then' [could do several other things instead, e.g. (command) with no arguments, (princ), (terpri), etc.]

  (progn ; 'else'

    (... the rest of the Lisp ...)

  ); progn

); if

 

or switch it around so you don't need any 'else' argument:

 

(if (...it doesn't find the support path...)

  (progn ; 'then'

    (... the rest of the Lisp ...)

  ); progn

); if [no 'else' -- do nothing if it finds it]

Kent Cooper, AIA
Message 6 of 10
CSM_MAI
in reply to: stevor

Do I have to specify a path since it's loaded with the other lisp files in the CUI?

Message 7 of 10
Kent1Cooper
in reply to: CSM_MAI


@CSM_MAI wrote:

Do I have to specify a path since it's loaded with the other lisp files in the CUI?


You don't need to specify a path if it's in the Support File Search Path list [and assuming there isn't any file of the same name in some other folder higher up on that list, that it would find first].

Kent Cooper, AIA
Message 8 of 10
dgorsman
in reply to: CSM_MAI

Don't forget about the new(ish) security settings which may prevent loading.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 9 of 10
scot-65
in reply to: CSM_MAI

Perhaps wrap a S::STARTUP around (load "external.lsp")?

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 10 of 10
CSM_MAI
in reply to: scot-65

That did it. The main lisp works, and still loads the external.lsp.  Thanks everyone for the help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost