PDA

View Full Version : Loading lisp code at start up



cadd4la
2006-01-30, 09:17 PM
Hi everyone,

I have a few questions on coding and having my code load at start up.

Background:

I use a master .lsp files that has these two examples of code in them for all of the codes that we use.

;;CodeName.lsp
(if (findfile (strcat lisp_path "CodeName.lsp"))
(load (strcat lisp_path "CodeName.lsp"))
)

and

;;CodeName.fas
(if (findfile (strcat lisp_path "CodeName.fas"))
(load (strcat lisp_path "CodeName.fas"))
)

Then in my ACADDOC.lsp file I have this.

(setq lisp_path "Z:\\CustomFiles\\")
(if (findfile (strcat lisp_path "Customfiles.lsp"))
(load (strcat lisp_path "Customfiles.lsp"))
)

I was in a class at AU that the speaker was showing a way to use a Autocom.lsp with the names of all your lisp files and this file will load from a Custom-menu.mnl file that you make.

In this Autocom.lsp all you use is this for each of you codes.

(autoload "CodeName" '("name to run the code"))

Questions:

1.) Is using the AutoCom.lsp file way a faster and/or easiser way to get AutoCAD to startup faster?

2.) When using the AutoCom.lsp I can't get it to run any .FAS files, does anyone know how to make it load .FAS files?

I would ask the speaker these questions but it looks to me that he only gives you one question and I used that up asking him about the things that I didn't need to use in his code example because I don't use ADT.

Thanks,

Kyle C.

rkmcswain
2006-01-30, 10:59 PM
(Autoload) just preloads the names of the commands, then loads the code it the command is executed. This saves a little time and memory, but unless you are loading some huge lisp files, I don't think it has a huge impact these days.

Having said that, I do use (autoload) in our "acaddoc.lsp" file for lisp files that are used frequently enough to define (and not have to use APPLOAD), but not used every single session of AutoCAD.

I have never tested it's actual impact on startup time, but we are fairly satisfied with the startup time (compared with OOTB installs of 2006, not R14) so it's a non-issue.

For your FAS files, do this:



(autoload "mycode.fas" '("cmdName"))

cadd4la
2006-01-30, 11:09 PM
rkmcswain,

Thank you for the info.

Kyle C.

whdjr
2006-01-31, 02:12 PM
As for your questions about an mnl file, I use them to load our files at startup and it works great. If you use custom menus then all you have to do is name the mnl file the same name as your custom menu file and it will load if it's in one of your support paths.

Here is an excerpt from our mnl file:

(load "Y:\\AutoCad 2006 ADT\\Configuration\\AutoLisp\\deloach_utilities_acad.lsp" '(princ))
(load "Y:\\AutoCad 2006 ADT\\Configuration\\AutoLisp\\room_tools.lsp" '(princ))
(load "Y:\\AutoCad 2006 ADT\\Configuration\\AutoLisp\\30x42.lsp" '(princ))
(load "Y:\\AutoCad 2006 ADT\\Configuration\\AutoLisp\\att.lsp" '(princ))
(load "Y:\\AutoCad 2006 ADT\\Configuration\\AutoLisp\\blank.lsp" '(princ))
(load "Y:\\AutoCad 2006 ADT\\Configuration\\AutoLisp\\context.lsp" '(princ))

Notice I included the entire path in this example, I do this just to eliminate the possibility of loading the wrong file.

I was taught when I started to NEVER modify the AutoCad files, add a custom menu to load your tools. I know alot of people differ on this opinion and I'm not going to tell how to do yours I was just telling you about ours. :)

Will

cadd4la
2006-01-31, 04:45 PM
Will,

Thanks for your input.

Kyle C.