muck Posted November 17, 2009 Posted November 17, 2009 What is the best way to load lisp routines. In older versions it use to be acad.lsp but AutoDesk changed that and sort of made it confusing. Also, is there a way to make your lisp routines load for each drawing is opened? I thought there was a variable setting for that? Thank you, Quote
alanjt Posted November 17, 2009 Posted November 17, 2009 Put everything in an acaddoc.lsp file. Quote
woodman78 Posted November 17, 2009 Posted November 17, 2009 Alanjt, one doesn't exist for 2010 vanilla. Do i create one? I tried this but my lisps still won't load. I want to run them from a ribbon panel by creating a new command. The new command contains as the macro the defun lisp title. Am I going down the wrong route?? Quote
alanjt Posted November 17, 2009 Posted November 17, 2009 Alanjt, one doesn't exist for 2010 vanilla. Do i create one? I tried this but my lisps still won't load. I want to run them from a ribbon panel by creating a new command. The new command contains as the macro the defun lisp title. Am I going down the wrong route?? Yes, you have to create the acad.lsp and acaddoc.lsp. Quote
woodman78 Posted November 17, 2009 Posted November 17, 2009 So do i put all my load lisps (load "A1.lsp") into the acaddoc.lsp and what goes into the acad.lsp file???? Quote
alanjt Posted November 17, 2009 Posted November 17, 2009 So do i put all my load lisps (load "A1.lsp") into the acaddoc.lsp and what goes into the acad.lsp file???? Nothing, the acad.lsp will only load once per session, the acaddoc.lsp will load for everything drawing. Also, when using load, put something either a sting or nil in the 2nd variable to avoid error stops in the event the file cannot be found. Example: Command: (load "alskdj") LOAD failed: "alskdj" Command: (load "alskdj" nil) nil Command: (load "alskdj" "Did not load!") "Did not load!" Also, look into autoload (autoload "LayerOff" '("LF" "LayerOff")) This will cut down on loading time, since it will only fully load the routine when you type in the alias for the first time. Quote
muck Posted November 18, 2009 Author Posted November 18, 2009 I have a lisp routine called 7.lsp that loads a series of lisp other routines I created. So load 7.lsp in acaddoc.lsp? Where is acaddoc.lsp or if I have to make one where do I put it on a network version of autocad? Quote
alanjt Posted November 18, 2009 Posted November 18, 2009 I have a lisp routine called 7.lsp that loads a series of lisp other routines I created.So load 7.lsp in acaddoc.lsp? Where is acaddoc.lsp or if I have to make one where do I put it on a network version of autocad? You have to create the acaddoc.lsp file and place it in any support path. If it's for a group of users, put it on a network. Version doesn't matter. Quote
woodman78 Posted June 17, 2010 Posted June 17, 2010 I have an acaddoc.lsp file made up like this: (Load "Bgblock" "bgblock.lsp failed to load") (Load "Bglegend" "bglegend.lsp failed to load") (Load "Bglegend1" "bglegend1.lsp failed to load") I have hundreds of lisps loading and it takes a while. How do I use autoload and will it help to speed things up? Quote
alanjt Posted June 17, 2010 Posted June 17, 2010 I have an acaddoc.lsp file made up like this: (Load "Bgblock" "bgblock.lsp failed to load") (Load "Bglegend" "bglegend.lsp failed to load") (Load "Bglegend1" "bglegend1.lsp failed to load") I have hundreds of lisps loading and it takes a while. How do I use autoload and will it help to speed things up? Yes, it will speed load times up. Straight from my signature: Load/AutoLoad Usage Quote
jammie Posted June 17, 2010 Posted June 17, 2010 I have an acaddoc.lsp file made up like this: (Load "Bgblock" "bgblock.lsp failed to load") (Load "Bglegend" "bglegend.lsp failed to load") (Load "Bglegend1" "bglegend1.lsp failed to load") I have hundreds of lisps loading and it takes a while. How do I use autoload and will it help to speed things up? I have a startup directory where I save all the Lisp files I want to be loaded into a drawing session. Using the following routine, which is saved into my Acaddoc.lsp, every lisp file saved into that directory gets autoloaded (defun AutoLoadLispDir (dir / FileLIst) (vl-load-com) (if (setq FileLIst (vl-directory-files dir "*.lsp" 1)) (progn (princ (strcat "\nLoading [" (rtos (length Filelist) 2 0) "] routines from " dir ) ) (foreach n FileLIst (setq LoadMsg "loaded ok!") (load (strcat dir "\\" n) nil) (princ (strcat "\n" n)) (repeat (- 50 (strlen n)) (princ ".")) (princ LoadMsg) ) ) ) ) (AutoLoadLispDir "c:\\AcadUser\\Lisp\\Startup" ) Just food for thought Quote
alanjt Posted June 17, 2010 Posted June 17, 2010 I have something very similar to that for loading subroutines... ((lambda (path) (vl-load-com) (if (findfile path) (foreach file (vl-directory-files path "*.LSP") (load (strcat path "\\" file) nil) ) ) ) "C:\\AlanThompson\\LSP\\_Subs" ) However, this will NOT help load times, AUTOLOAD will. BTW, Jammie, you should read the link I posted. It explains the issues of using the load function and not filling the second parameter. Quote
woodman78 Posted June 17, 2010 Posted June 17, 2010 How do i structure a line for Autload? it isn't very clear on a few of the websites. Quote
alanjt Posted June 17, 2010 Posted June 17, 2010 How do i structure a line for Autload? it isn't very clear on a few of the websites. Did you read the link I posted? Quote
jammie Posted June 17, 2010 Posted June 17, 2010 Jammie, you should read the link I posted. It explains the issues of using the load function and not filling the second parameter. Good point, thanks. Previous code updated Quote
alanjt Posted June 17, 2010 Posted June 17, 2010 Good point, thanks. Previous code updated You're welcome. Quote
woodman78 Posted June 17, 2010 Posted June 17, 2010 I got it now. I am browsing at 60% so i didn't see it. Quote
woodman78 Posted June 18, 2010 Posted June 18, 2010 Alanjt, I have change my acaddod to use the autoload but now only the first lisp loads and none of the others do. Due to an error in the first lisp. I get this after the lisp has run: Command: A1 Unknown command "A1". Press F1 for help. This is the lisp: (defun c:A1 () (if (findfile "T:/Drawing Tools/Templates/CCC2009.dwt") (progn (command "_.psetupin" (findfile "T:/Drawing Tools/Templates/CCC2009.dwt") "*" ) (while (wcmatch (getvar "cmdnames") "*PSETUPIN*") (command "_yes") ) ;_ while T ) ;_ progn ) ;_ if (command "-plot" "n" "" "A1" "" "n" "y" "n") (command "regenall") (command "_zoom" "e" "") (princ) ) What can be causing this? Do i need another (princ) somewhere to silence that? Quote
alanjt Posted June 18, 2010 Posted June 18, 2010 Alanjt,I have change my acaddod to use the autoload but now only the first lisp loads and none of the others do. Due to an error in the first lisp. I get this after the lisp has run: Command: A1 Unknown command "A1". Press F1 for help. This is the lisp: (defun c:A1 () (if (findfile "T:/Drawing Tools/Templates/CCC2009.dwt") (progn (command "_.psetupin" (findfile "T:/Drawing Tools/Templates/CCC2009.dwt") "*" ) (while (wcmatch (getvar "cmdnames") "*PSETUPIN*") (command "_yes") ) ;_ while T ) ;_ progn ) ;_ if (command "-plot" "n" "" "A1" "" "n" "y" "n") (command "regenall") (command "_zoom" "e" [color=Red]""[/color]) (princ) ) What can be causing this? Do i need another (princ) somewhere to silence that? Remove the extra "" from the zoom call (marked in red). BTW, just out of curiosity, did you get the coding to import the PageSetups from AT: PageSetups? It's just exact same coding I used. Quote
Recommended Posts
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.