Author Topic: Autoloaded .lsp programs stuck in initializing loop on first run  (Read 3969 times)

0 Members and 1 Guest are viewing this topic.

0john0

  • Guest
Hi again, and Happy New Year!

I'm having issues with files autoloaded via ACADDOC.LSP getting stuck in an "Initializing..." loop when run for the first time in a new drawing.

I've only tried it with two different .lsp files so far, and both behave slightly differently. Both have "OK" and "Cancel" buttons, and the code is the same for those functons, however...

The first one (my batch plotter I've had help with on here before) will show the "Initializing..." message until "OK" or "Cancel" is pressed, and then it will disappear.

The second (an automated insertion tool for drawing border blocks) will show the "Initializing..." even when "Cancel" is pressed, or when the function has completed. It only disappears once you hit "Esc" or perform another command.

The odd thing is tht this only occurs the first time either are run in a new drawing. Also the issue doesn't occur if the files are loaded using the "load" command in ACADDOC.LSP rather than the "autoload" command.

I've seen a few posts elsewhere that the built-in "autoload" in the acad20XXdoc.lsp has an inherent flaw that causes this, and that Lee Mac created a new autoload.lsp which overcame these issues. I've managed to get a copy of Lee's code and added it, however I'm still having the same problem of getting stuck in a "Initializing..." loop on first run.

The loop can be exited quite easily, or I can get around it by using the "load" command - but neither of these actaully fix the issue.

Any suggestions welcomed  :-)

Cheers,

John

tombu

  • Bull Frog
  • Posts: 288
  • ByLayer=>Not0
Re: Autoloaded .lsp programs stuck in initializing loop on first run
« Reply #1 on: January 04, 2019, 12:00:47 PM »
Not all command calls work in acaddoc.lsp and don't use anything that requires user input.
Using S::STARTUP inside acaddoc.lsp may be a better option: https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2019/ENU/AutoCAD-Customization/files/GUID-FDB4038D-1620-4A56-8824-D37729D42520-htm.html

Otherwize put a few (princ "Got Here!")'s in your acaddoc.lsp to track down what's hanging it up.  It could be a simple spelling error.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Autoloaded .lsp programs stuck in initializing loop on first run
« Reply #2 on: January 04, 2019, 02:04:15 PM »
I've seen a few posts elsewhere that the built-in "autoload" in the acad20XXdoc.lsp has an inherent flaw that causes this, and that Lee Mac created a new autoload.lsp which overcame these issues. I've managed to get a copy of Lee's code and added it, however I'm still having the same problem of getting stuck in a "Initializing..." loop on first run.

Are you certain that your autoload expressions are evaluating my version of the function as opposed to the function defined in the acad20XXdoc.lsp file?

To test this, assuming you are using the code I posted here, I would suggest changing:
Code: [Select]
(defun autoload ( app lst ) (LM:autoload "lsp" app lst))
To:
Code: [Select]
(defun myautoload ( app lst ) (LM:autoload "lsp" app lst))
And changing your autoload expressions accordingly to instead call the function myautoload, and then test again.

0john0

  • Guest
Re: Autoloaded .lsp programs stuck in initializing loop on first run
« Reply #3 on: January 04, 2019, 05:55:37 PM »
I've seen a few posts elsewhere that the built-in "autoload" in the acad20XXdoc.lsp has an inherent flaw that causes this, and that Lee Mac created a new autoload.lsp which overcame these issues. I've managed to get a copy of Lee's code and added it, however I'm still having the same problem of getting stuck in a "Initializing..." loop on first run.

Are you certain that your autoload expressions are evaluating my version of the function as opposed to the function defined in the acad20XXdoc.lsp file?

To test this, assuming you are using the code I posted here, I would suggest changing:
Code: [Select]
(defun autoload ( app lst ) (LM:autoload "lsp" app lst))
To:
Code: [Select]
(defun myautoload ( app lst ) (LM:autoload "lsp" app lst))
And changing your autoload expressions accordingly to instead call the function myautoload, and then test again.

Hi Lee,

Yes, that's exactly where I found it  :-) Yours and others websites, tutorials, and forum contributions have been invaluable in getting my head around Lisp programming!

I did test that earlier when I was at work by removing one of the referenced .lsp files from the directory and trying to run it after restarting AutoCAD. The error message returned was from your autoload script rather than the AutoCAD one - I couldn't find an error message that contained the word "resides" in the acad2018doc.lsp  :wink:

I'm using AutoCAD 2018, and the ACADDOC.LSP and your autoload.lsp are stored in a directory in a server, but that path is setup as a support path.

The odd thing is the issue only occurs the first time you run either .lsp in a new drawing, if you run it a second time it is fine. Using "load" as opposed to "autoload" also doesn't generate the issue?

Cheers,
.
John

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Autoloaded .lsp programs stuck in initializing loop on first run
« Reply #4 on: January 04, 2019, 06:42:32 PM »
Yours and others websites, tutorials, and forum contributions have been invaluable in getting my head around Lisp programming!

Excellent to hear  :-)

The odd thing is the issue only occurs the first time you run either .lsp in a new drawing, if you run it a second time it is fine. Using "load" as opposed to "autoload" also doesn't generate the issue?

As a stab in the dark, try adding (princ) on a new line at the end of the LISP file you are trying to load using the autoload function.

0john0

  • Guest
Re: Autoloaded .lsp programs stuck in initializing loop on first run
« Reply #5 on: January 07, 2019, 11:31:04 AM »
Yours and others websites, tutorials, and forum contributions have been invaluable in getting my head around Lisp programming!

Excellent to hear  :-)

The odd thing is the issue only occurs the first time you run either .lsp in a new drawing, if you run it a second time it is fine. Using "load" as opposed to "autoload" also doesn't generate the issue?

As a stab in the dark, try adding (princ) on a new line at the end of the LISP file you are trying to load using the autoload function.

I think I may have actually been worrying about nothing  :nerdyembarassed:

Having looked at it again today I think it is just the time it takes for the last princ message ("Initializing...") in the autoload function (either in acad2018doc.lsp or in your autolaod.lsp) to decay from the command prompt that was concerning me. If I leave it a few seconds it fades away.

It must be the first time I'd noticed it and started thinking I'd messed something up!  :nerdyembarassed:

Cheers!