Jump to content

Recommended Posts

Posted

Am I using acad.lsp and acaddoc.lsp poorly?

 

I am using defun-q and appending S::STARTUP (as per the help files). This much works in general.

 

The ony problem is if they have local variables. On autocad startup, the acad.lsp is added to S::STARTUP. Then the acaddoc.lsp is added to S::STARTUP. For arguments sake, lets assume acad.lsp is the first thing in the S::STARTUP (nothing before it). In this case, the acad.lsp functions will load just fine, then the S::STARTUP will cancel because it reads the ( / local variables) line from the acaddoc.lsp, which are now somewhere in the middle of the S::STARTUP - no longer defined as local variables. Of course the error is a numberp nil because it treats it as division.

 

I hope this all makes sense. Do any of you have suggestions or other methods to try? I appreciate the help.

 

p.s. the acaddoc.lsp loads just fine on any subsequent drawings opened after startup, when acad.lsp is not loading...so I am pretty positive it is the local variables shown in the middle of the S::STARTUP causing the error.

Posted

It sounds to me like there's a problem with ACAD.lsp, and not so much with S::Startup... I cannot be sure unless you post your code.

 

That said, I also feel that you're misunderstanding how to properly use ACAD.lsp, ACADDOC.lsp, and S::Startup. I'm unsure why you require S::Startup, if you're controlling both ACAD.lsp, and ACADDOC.lsp files.

 

Real quickly, here's a summary:

 

ACAD.lsp - A user defined LISP file that loads once per session, by default (depending on the status of ACADLSPASDOC system variable).

 

ACADDOC.lsp - A user defined LISP file that loads once per drawing open.

 

SS:Startup - One step of many during the startup sequence

 

Startup sequence:

 

A. CUI files loaded:

1. Enterprise

2. Main

3. Partials to Main

4. Partials to Enterprise

 

B. acad*.* files loaded:

1. Files listed in acad.rx

2. acad2009.lsp

3. acad.lsp

4. acad2009doc.lsp

5. acaddoc.lsp

6. acad.dvb

 

C. CUI-associated MNL and LSP files loaded:

1. Enterprise named MNL

2. Enterprise loaded LSP and MNL

3. Main named MNL

4. Main loaded LSP and MNL

5. Partials to Main named MNLs

6. Partials to Main loaded LSPs and MNLs

7. Partials to Enterprise named MNLs

8. Partials to Enterprise loaded LSPs and MNLs

 

D. Startup suite files loaded

 

E. Startup routines run:

1. AcadStartup() called (AutoCAD startup)

2. AcadDocument_Activate() called (Drawing startup)

3. (S::STARTUP) called

4. SCR loaded from /b switch

Source

 

HTH

Posted

Thanks for the reply and info on the sequence. I'm using the acad.lsp and acaddoc.lsp in case we want to include any (command...) calls. If we add any of that, as I understand, it needs to run after initialization. In any case, both routines work......just not if we include local variables. I could get rid of local variables and make longer lines of code I guess....or I could run both without appending S::STARTUP, but I would need to avoid (command....) lines in the code.

 

below are the acad.lsp and acaddoc.lsp files I am testing with right now. On startup of the program, the S::STARTUP will run the code from acad.lsp and then stop at ( / *error* loginlsp) from the acaddoc.lsp. If I then start a new drawing, the code in acaddoc.lsp loads fine, because ( / *error* loginlsp) is now at the top of S::STARTUP. Any comments/ideas? Thanks.

 

;;acad.lsp
(defun-q acadSTART ( / *error* )

(defun *error* (msg)
 (setvar "cmdecho" 1)
 (princ (strcat "\n " msg))
 (princ)
)
(setvar "cmdecho" 0)
(load "I:\\lja-std\\ACAD\\Lisp\\Check-Paths.lsp" "Check-Paths not loaded")

(prompt "\n acad.lsp loaded")
(setvar "cmdecho" 1)
(princ)
);end defun-q acadStart

(setq S::STARTUP (append S::STARTUP acadSTART)

 

;;acaddoc.lsp
(defun-q acaddocSTARTUP ( / *error* loginlsp )

;;error handler
(defun *error* (msg)
 (setvar "cmdecho" 1)
 (princ (strcat "\n " msg))
 (princ)
)

(setvar "cmdecho" 0)

;;load commonly used standard lisp routines
(load "I:\\lja-std\\ACAD\\Lisp\\LID.lsp" "LID not loaded")
(load "I:\\lja-std\\ACAD\\Lisp\\RVIEW.lsp" "RVIEW not loaded")
(load "I:\\lja-std\\ACAD\\Lisp\\RVIEW2.lsp" "RVIEW2 not loaded")
(load "I:\\lja-std\\ACAD\\Lisp\\DVIEW2.lsp" "DVIEW2 not loaded")

;;User startup routine (user routine should be located in the User_Customizations
;;folder and named "userlogin".lsp - example rharenberg.lsp)
(setq loginlsp (strcat (getvar "loginname") ".lsp"))
(if
(not
 (=
  (findfile
(strcat "I:\\ljastd\\ACAD\\User_Customizations\\"(getvar"loginname")"[url="file://\\"loginlsp"]\\"loginlsp[/url])) nil
 )
)

(load (strcat "I:\\lja-std\\ACAD\\User_Customizations\\"(getvar "loginname")"[url="file://\\"loginlsp"]\\"loginlsp[/url]) "user lisp not loaded")
)

(prompt "\n acaddoc.lsp loaded")
(setvar "cmdecho" 1)
(princ)
);;end defun-q acaddocSTARTUP

(setq S::STARTUP (append S::STARTUP acaddocSTARTUP))

Posted

I'm not sure where you're getting the 'don't use command calls during ACAD.lsp/ACADDOC.lsp load' bit... I've never had any issues with either defining a custom function (using DEFUN), or auto aging a sequence of steps at drawing open.

 

If for some reason you're experiencing an issue with specific command calls, then try to document which commands here so we may better help you deduce the issue. Perhaps you're calling a command that has not yet been initialized due to a critical MNL file having not yet been loaded? Not really sure. The more info you can offer the better the possibility of getting a solution.

 

Separately, if needing to call command(s) after all other files are loaded/initialized, consider using the /B Startup Switch to call a Script file.

Posted

I got that info from the help files:

"The startup LISP files (acad.lsp,acaddoc.lsp, and MNL) are allloaded into memory before the drawing is completely initialized. Typically,this does not pose a problem, unless you want to use the command function, which isnot guaranteed to work until after a drawing is initialized."

In any case, since you have not had or heard of any issues just using defun, I will follow that route. I have changed the routines to not use S::Startup anymore - no issues so far. I'll repost if there are any issues with the command calls (most likely I got worried about the unknown when I read the help file portion above).

Thanks again for the assistance.

Posted

No worries; I'll try to dig up more on the initialization, but what this means (in my experience) has nothing to do with the actual code you've written, and represents an issue that I've experienced when invoking routines via ACADDOC.lsp when being opened from Sheet Set Manager (SSM) instead of using the standard open file dialog.

 

In this situation, I was successfully able to initialize the drawing by simply clicking my mouse within the drawing area, which THEN triggered the routine(s) to run as desired. Hopefully that makes sense.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...