R2005: I have a lisp routine that saves the user profile. I put it in my acad.lsp. (load "Save_Login_Profile") ;saves profiles. (Save_Login_Profile) I also set the acadlspasdoc variable to 0 at the beginning of my acad.lsp. Yet each time I open a new or existing drawing, I see displayed on the screen the prompt that is associated with this program. "G:\Autolisp\AutoCAD_2004_Support\Profiles\BZONDLO.arg saved." Isn't acad.lsp only suppose to load on the first drawing when AutoCAD is first opened? I didn't notice this in 2004 but it may have been that way also. TIA Bill
You've pointed out your problem yourself: <snip> I also set the acadlspasdoc variable to 0 at the beginning of my acad.lsp. <snip> Setting acadlspasdoc tells AutoCAD to reload Acad.lsp for each document opened (which is what acaddoc.lsp is for). -- Gary J. Orr CADD Administrator (218) 279-2421 LHB, Inc 21 West Superior Street, Suite 500 Duluth, Mn 55802 (218) 727-8446 www.LHBcorp.com screen the prompt that is associated with this program.
<<<quote>>> Setting acadlspasdoc tells AutoCAD to reload Acad.lsp for each document opened (which is what acaddoc.lsp is for). <<<quote>>> Gary, I'm trying to understand your post. Are you saying that setting the acadlspasdoc variable causes AutoCAD to reload Acad.lsp for each document no matter if it's set to 0 or 1? The help files says: 0 Loads acad.lsp into just the first drawing opened in an AutoCAD session. 1 Loads acad.lsp into every drawing opened . Bill
My apologies, I read your post a little too quickly. You are correct setting it to 0 should provide you with the desired effect. I had run into a similar situation in the past, so in form of recompense, here is how I usually handle the situation now: ;this checks for a variable to determine weather or not to run (if (= nil savedprofile) (progn (load "Save_Login_Profile") ;saves profiles. (Save_Login_Profile) ;The following creates a variable and sends it ;to all consecutive drawings opened during this editing session (setq savedprofile T) (vl-propagate savedprofile);sends the variable to all consecutive drawings opened );close progn );end if This method can be used in either Acad.lsp or AcadDoc.lsp -- Gary J. Orr CADD Administrator (218) 279-2421 LHB, Inc 21 West Superior Street, Suite 500 Duluth, Mn 55802 (218) 727-8446 www.LHBcorp.com reload Acad.lsp for each document no matter if it's set to 0 or 1?
This may be different than I thought. I added the code that you posted but AutoCAD acts the same. I even tried the if statement before the s::startup but it doesn't change anything. (if (= nil savedprofile) (progn (defun s::startup () And it still runs the acad.lsp evertime I open a new drawing. Wnen I check the value of savedprofile. Command: !savedprofile T And I've checked the spelling of the (setq savedprofile T) to be sure it's checking the same var. Bill
Well I was wrong. Evidently when acad loads the acad.lsp, the var value for the next drawing is not available. savedprofile returns nil at this time so the acad.lsp runs anyway. This have got to be a problem within the Acad executible. For some reason it loads the acad.lsp no matter what the acadlspasdoc variable is set at. This would have been a good work around. Bill
This is really bizzare. I have my lispinit = 0 so I know the value of savedprofile is T all the time. Yet that acad.lsp loads and runs. Even with: (princ "\nsavedprofile ")(princ savedprofile) (if (= nil savedprofile) (progn (load "Save_Login_Profile") ;saves profiles. (Save_Login_Profile) (setq savedprofile T) (vl-propagate savedprofile) ;sends the variable to all consecutive drawings opened. );close progn );end if The princ savedprofile return T right before the if. Command: DOSLib Version 6.1.3 (Nov 21 2003) Loaded savedprofile T G:\Autolisp\AutoCAD_2004_Support\Profiles\BZONDLO.arg saved. Command: I don't get it. Am I missing something? Bill
Sorry, I was on something else... If the routine fails when running from acad.lsp, have you tried moving it to acaddoc.lsp? If that fails place it within S::Startup (as you had mentioned earlier) and be sure that your startup is in acaddoc.lsp. Another problem with startup is that it may already exist (from some other add-on for example) so place the following in your acaddoc.lsp: ;start code (defun your_startup () (princ "\n\nRunning Start UP: ") (if (= nil savedprofile) (progn (load "Save_Login_Profile") ;saves profiles. (Save_Login_Profile) ;The following creates a variable and sends it ;to all consecutive drawings opened during this editing session (setq savedprofile T) (vl-propagate savedprofile);sends the variable to all consecutive drawingsopened );close progn );end if (princ "\nDone.") (princ) ) (defun-q your_startup-q () (princ "\n\nRunning Start UP-q: ") (if (= nil savedprofile) (progn (load "Save_Login_Profile") ;saves profiles. (Save_Login_Profile) ;The following creates a variable and sends it ;to all consecutive drawings opened during this editing session (setq savedprofile T) (vl-propagate savedprofile);sends the variable to all consecutive drawingsopened );close progn );end if (princ "\nDone.") (princ) ) (if s::startup (setq s::startup (append s::startup your_startup-q)) (setq s::startup your_startup) ) ;end code -- Gary J. Orr CADD Administrator (218) 279-2421 LHB, Inc 21 West Superior Street, Suite 500 Duluth, Mn 55802 (218) 727-8446 www.LHBcorp.com is not available. savedprofile returns nil at this time so the acad.lsp runs anyway. it loads the acad.lsp no matter what the acadlspasdoc variable is set at.
Based upon your error: <snip> Invalid attempt to access a compiled function definition. You may want to define it using defun-q: #<SUBR @0c106b18 S::STARTUP> <snip> Lets scratch the fancy and do the dirty (again in AcadDoc.lsp) ;start code (defun-q your_startup-q () (princ "\n\nRunning Start UP-q: ") (if (= nil savedprofile) (progn (load "Save_Login_Profile") ;saves profiles. (Save_Login_Profile) ;The following creates a variable and sends it ;to all consecutive drawings opened during this editing session (setq savedprofile T) ;sends the variable to all consecutive drawings opened (vl-propagate savedprofile) );close progn );end if (princ "\nDone.") (princ) ) (if s::startup (setq s::startup (append s::startup your_startup-q)) (setq s::startup your_startup-q) ) ;end code -- Gary J. Orr CADD Administrator (218) 279-2421 LHB, Inc 21 West Superior Street, Suite 500 Duluth, Mn 55802 (218) 727-8446 www.LHBcorp.com Again thanks! But if I do it exactly like you say, I get an error on loading. Regenerating model. AutoCAD Express Tools Copyright © 2002-2004 Autodesk, Inc. SavedProfile: nil; error: Invalid attempt to access a compiled function definition. You may want to define it using defun-q: #<SUBR @0c106b18 S::STARTUP> BZONDLO menu utilities loaded. If I don't use the s::startup at all (I don't have any other apps that may have an s::startup) Then the code loads every drawing even though it's only in the acaddoc.lsp and savedprofile = T upon drawing opening. I tried not using an acad.lsp at all and had the same results. I'll attach a copy of acad.lsp and acaddoc.lsp. Thanks again Bill
Inerestingly enough I did finally get the work around. One problem that caused my prior attempt to fail was: I had to use (vl-propagate 'savedprofile) instead of (vl-propagate savedprofile). They both returned T when executed....well....That'll be our little secret. My acad.lsp now looks like this: (defun s::startup () (vl-load-com) (if (= nil savedprofile) (progn (load "g:/autolisp/AutoCAD_2004_Support/my_startup") ;program containing preference setup. (my_startup) ) ) ;---; ) ;end s::startup defun (princ) ;silent load. With the my_startup routine containing the (setq savedprofile T) and the vl-propagate with all my setup calls. I left my acaddoc.lsp with no changes and I created the my_startup subr in the support directory. Seems to work fine now. Thanks Bill
The need to quote the variable surprises me (I've never had to). Are you running 2004 products or 2005? I'm testing and running on 2004. I think that you've just answered another thing that has previously bugged me... I've often wondered why I could sometimes use (defun... and sometimes had to use (defun-q... It begins to seem to me that Acad.lsp does the compiling of the S::Startup; Therefore start up routines launched from Acad.lsp do not require the defun-q, as it is processed PRIOR to compiling, while those defined in AcadDoc.lsp do require the defun-q as they are processed AFTER startup is compiled. I'm glad that I stayed with it to the end ;-) -- Gary J. Orr CADD Administrator (218) 279-2421 LHB, Inc 21 West Superior Street, Suite 500 Duluth, Mn 55802 (218) 727-8446 www.LHBcorp.com savedprofile). They both returned T when executed....well....That'll be our little secret. vl-propagate with all my setup calls.
<<<The need to quote the variable surprises me (I've never had to). Are you running 2004 products or 2005? I'm testing and running on 2004.>>> I am on 2005 and was surprised to have problems being I just got set up in 2004 with no troubles like this. I found the quote thing in the help files ( I thought at first it worked without the quote). I and also fount and example of the defun-q that used a quote with the append function: (append s::startup 'my_startup-q) but have not tested it. <<<I'm glad that I stayed with it to the end ;-) >>> Sometimes to me posting is like talking out loud, it helps me think. :^) Thanks for being there. Bill