Keeping custom lisp programs loaded in memory when drawings are closed....

Keeping custom lisp programs loaded in memory when drawings are closed....

Anonymous
Not applicable
1,575 Views
5 Replies
Message 1 of 6

Keeping custom lisp programs loaded in memory when drawings are closed....

Anonymous
Not applicable

I currently have all of my custom lisp programs located inside the acad2020doc.lsp (or previous version of the file according the corresponding autocad installation) so they load up in memory when a drawing files is open. As the years have passed by, the number of custom lisp programs has increased and the size of that file containing them has increased accordingly. Needless to say, this has a noticeable effect on how long it takes for a drawing to open.

I would like to know if there is a way to load all of those lisp programs once when autocad initially starts and keep them resident in memory to be accessible for execution on any of the open drawings when required without having them to load every time a drawing is open. Any help here will be greatly appreciated.

Thanks.

0 Likes
Accepted solutions (1)
1,576 Views
5 Replies
Replies (5)
Message 2 of 6

CodeDing
Advisor
Advisor
Accepted solution

@Anonymous ,

 

I HIGHLY recommend you remove your lisps from your acaddoc.lsp file and create your own file(s). Once you have done that, I will encourage you to have some sort of "utilities.lsp" file that contains "helper" or utility functions that your lisps can utilize (since these would need to be loaded each time). Then for your custom commands, you need to decide if the AUTOLOAD function can be of use to you (since it would only load lisp files once a specific command is called). This will save you much loading heartache.

 

Best,

~DD

0 Likes
Message 3 of 6

Anonymous
Not applicable

Thanks

0 Likes
Message 4 of 6

martti.halminen
Collaborator
Collaborator

First of all, acaddoc2020.lsp is the wrong place for this. That should only contain Autodesk stuff, as in any updates etc. they feel free to clobber any previous contents.

 

Your own stuff should be in acaddoc.lsp, instead. (Create it if it doesn't exist.)

 

- What you are literally asking for is impossible as each drawing has its own Lisp environment (unless you are running in the Single Document Interface mode).

 

Next step would be moving your stuff to separate files for maintainability, so you can manually load them for debugging without going via acaddoc.lsp. When you get them debugged, add loading calls to those files into your acaddoc.lsp file.

 

While the autoload tricks do function, I find those unnecessary historical ballast from MS-DOS times.

 

It is much easier to just collect all your stuff into a .vlx file and load that when starting, assuming the parts are not mutually incompatible. (As they must be, if you have managed to load them all via acaddoc.)

 

We are loading our standard Lisp environment as one .vlx file via acaddoc.lsp, takes about 0.8 seconds.

That file is built from 77 separate .lsp files, about 33000 program lines, about 1600 defuns.

 

-- 

 

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

Good advice. I have removed everything from the acaddoc2020.lsp and created a dedicated vlx file to contain all of our custom functions. I timed it and did not see any improvement on loading time in our particular case. However, this is a more elegant way of keeping everything organized.

Cheers,

0 Likes
Message 6 of 6

martti.halminen
Collaborator
Collaborator

If changing to .vlx didn't help with the loading speed, that means that the part taking time probably isn't loading the Lisp program text itself, but that in addition to loading defuns, your programs either also execute something during loading, or load something using not fully defined paths, so the system searches all the support file search path, or printer support path etc. for something. If you have slow network disks in the paths, especially something that only fails after a timeout, that could waste some time.

0 Likes