Jump to content

Load a LISP Routine Only on Session Start


lamensterms

Recommended Posts

Hey,

 

I've just changed jobs, and the new office runs ACAD 2017, on Windows 10.

 

As usual with new OS and ACAD, I'm finding a few issues to troubleshoot.... one of which is an annoying (understatement) issue which crashes ACAD, caused by aeccore.crx.

 

I've found that if I can force aeccore.crx to initiate at the beginning of a session, all is OK.  If I have had the session open for a little while, then initiate aeccore.crx... crash.

 

So... I would like to load and run a routine that will force aeccore.crx to initiate at the beginning of the session, and not when I open each drawing.  Is this possible?

 

Thanks for any help

Link to comment
Share on other sites

Thanks for the reply BIGAL.

 

Is it correct that the Startup Suite will load for every drawing?  I only wish to load a particular lisp at session start (and not load for each DWG)

Link to comment
Share on other sites

I'd make this into a LISP with a global string, if string is nil then do what you want at first opening CAD. After that is defined run the command in the LISP and set the file to load at startup

 

LISP might be (untested):

(defun c:loadaeccore ( / )
  (if (= aeccoreloaded nil)
    (progn
--DO WHATEVER YOU WANT AT INITIAL STATUP HERE--
      (setq aeccoreloaded "Loaded")
    ) ;;end progn
  } ;;end if
  (princ aeccoreloaded)
  (princ)
)
(c:loadaeccore)

 

  • Like 1
Link to comment
Share on other sites

Why not just load it with acad.lsp?

As long as ACADLSPASDOC (System Variable) is set to it's initial value of 0 acad.lsp only loads when the first drawing is opened in a session.

Don't use acaddoc.lsp to load it as it would load every time a drawing is opened which works well for most lisp routines.

  • Like 3
Link to comment
Share on other sites

@tombu nailed it, there is much to be said for consistency.   :beer:

 

I just stumbled across this in the SYSVDLG, and was about to ammend my earlier suggestion.

Here is the screenshot.

 

image.thumb.png.02f682dd5b266117508e3d669a8d6a32.png

  • Like 1
Link to comment
Share on other sites

Thanks for the replies guys.

 

@Dadgad I'll do some reading about that sysvar... not sure if that will effect my LISP loading - I'll check it out.  Definately ACADLSPASDOC could be the go!

 

@Steven P Good suggestion for a quick work-around.  I've gone with this solution for now, though I used :

(setenv "aeccoreloaded" "Loaded")

 

@tombu I think this is exactly what I was looking for, thank you!

 

Thanks guys

 

  • Like 1
Link to comment
Share on other sites

SYSVDLG just opens the Pandora's Box of all Autocad commands, and explains all available options.

It is a quick trip into the belly of the System Variables Beast.

I favor cursor scrolling through any area that might seem to be of interest, because then the dialog

box opens, providing a very quick, on the fly review of what the variable does.

Spend some down time going through it, you'll learn plenty, and be glad you did.  :beer:

  • Like 1
Link to comment
Share on other sites

4 hours ago, lamensterms said:

 


(setenv "aeccoreloaded" "Loaded")

 

Won't saving 'Loaded' in the registry keep that value even when you close and restart AutoCAD, if you save it as a string it will clear when you restart AutoCAD

 

 

  • Like 1
Link to comment
Share on other sites

Many elite coders avoid Express Tools because some still have bugs (most easily fixed by replacing "command" calls with "command-s") in them but Help for them has been included  in AutoCAD help in recent versions and I've used them since they started out as Bonus Tools. Many of them have been added as regular AutoCAD commands (most of the Layer commands for example), others have been dropped, while others around longer than Bonus Tools like Getsel.lsp and SSX.lsp are still considered Express Tools. Like Dadgad I use SYSVDLG (System Variable Editor…) and ALIASEDIT (Command Alias Editor…) on a regular basis as they provide a quick, simple, and helpful interface that eliminates simple mistakes.

 

While some system variables are persistent, some are saved in the drawing, and some aren't saved at all when a drawing is closed environmental variables are saved in the Windows Registry where they remain unchanged. Keep in mind environmental variables saved in profiles may be different after switching profiles.

  • Like 2
Link to comment
Share on other sites

On 7/19/2021 at 6:06 PM, Steven P said:

 

Hi Steven, Dadgad & Tombu,

 

Oh, right you are!  I had found that using SETQ would only save the string in the current DWG.  This would cause my 'AECCORELOAD' command to run each time I open a drawing - which I am hoping to avoid.  Do you know of any other way to save a user variable for the current session?  In the meantime I can use Tombu's solution (though I haven't tested yet).

 

I too am very fond of SYSVDLG, use it regularly to read up on SYSVARs, but to my mild shame I haven't taken the time to commit much of it to memory!  Maybe on a quiet Sunday afternoon or 2 (or 3), I'll spend some real time getting further acquainted with it😅

 

Thanks again for your help everyone!

Link to comment
Share on other sites

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...