Bill Tillman Posted January 13, 2012 Share Posted January 13, 2012 I know how to have LISP codes autoload when you start AutoCAD but this question is about something different. The code I've prepared is not needed except when the users are doing a specialized task and therefore we don't want it to load and take up resources each time they open AutoCAD. Is there a way to launch AutoCAD, have it autoload this specific LISP code and then execute it? The whole process starts with the user in an Excel file with a macro which writes some of it's data to a text file. The user then opens AutoCAD, loads the LISP file and runs it and it uses the text file the macro just created. Ideally, I would like to take as much of the user interface out of this as possible. And really to be idealistic I'd like the macro in Excel to not only write the text file but to also launch AutoCAD in this special mode where it will autoload the LISP file and run it. Is anything like this possible? Perhaps a batch file with some switches for AutoCAD to know that this time we want to load the new LISP program and run it. Quote Link to comment Share on other sites More sharing options...
pBe Posted January 13, 2012 Share Posted January 13, 2012 "drive:pathname\acad.exe" ["drawingname"] [/switch "name"] When using a switch option, you must follow the switch with a space and then the name of a file, path, or view within quotation marks. For example, the following entry starts the program from a folder named AutoCAD 2010 with the drawing template arch1.dwt, restores a named view PLAN1, and executes a script file startup.scr. "d:\AutoCAD 2010\acad.exe”/t "d:\AutoCAD 2010\template\arch1" /v "plan1" /b "startup" /b Script name Designates a script to run after you start the program (b stands for batch process). Scripts can be used to set up drawing parameters in a new drawing file. An SCR file type is assumed. /ld ARX or DBX application Loads a specified ARX or DBX application. Use the following format: \.ARX If the path or file name contains spaces, then the path or file name should be wrapped in double quotes. If no path information is included, the program search path is used. Quote Link to comment Share on other sites More sharing options...
Bill Tillman Posted January 13, 2012 Author Share Posted January 13, 2012 Wow, this is so cool. I found a way this morning to edit the Excel Macro and it now writes the text file, opens AutoCAD with the required drawing in it. Now all that's left to do is to have the proper LISP file loaded and have it execute. That said, and with what you have included above may I ask these questions. By script file you mean something other than a *.lsp file. OR can it do the same with my VLISP file? If only a script file can be executed can I include instructions in that script file to load and execute the VLISP file? Thanks again for your reply. I'm getting a real immersion into this process and it's starting to gel now. Quote Link to comment Share on other sites More sharing options...
pBe Posted January 13, 2012 Share Posted January 13, 2012 By script file you mean something other than a *.lsp file. OR can it do the same with my VLISP file? If only a script file can be executed can I include instructions in that script file to load and execute the VLISP file? Yes. you can call a lisp function within the script sample contents of a script _.open "D:\path\sheet1.dwg" (lisp_command_function) _.save _Y _.close _.open "D:\path\sheet2.dwg" (lisp_command_function) _.save _Y _.close where (lisp_command_function) is the lisp function name ... (defun c:funtionname ()...) (defun functionname ()...) or even this when lisp rouitne is not pre-loaded _.open "D:\path\sheet1.dwg" (load "C:\\LSP\\lisptorun" "Load Error Message") _.save _Y _.close _.open "D:\path\sheet2.dwg" (load "C:\\LSP\\lisptorun" "Load Error Message") _.save _Y _.close where lisptorun executes when loaded (defun functionname ()....);end of defun (functionname) Quote Link to comment Share on other sites More sharing options...
Bill Tillman Posted January 13, 2012 Author Share Posted January 13, 2012 Ok, I really want to be sure I'm following you here. In my case the LISP file will not be preloaded. It's only need once in a while and I can't have it autoloading unless the user really needs it. _.open "D:\path\sheet1.dwg" (load "C:\\LSP\\lisptorun" "Load Error Message") _.save _Y _.close If I had the above line in a text file which I called startmeup.scr....does 1. The (load "C:\\LSP\lisptorun" ...) part need to be enclosed in parenthesis as shown? 2. The _.save _Y _.close portion would be to close the actual CAD drawing file? In my case I don't really want it to close automatically. That is one of the things we're leaving up to the user after they print and/or save the file under a new name. 3. The file listtorun.lsp would be loaded but will this start it executing automatically? I am a little confused at the last part of your posting which shows (defun functionname ().... etc....Is this part of the syntax and is it required to make the script run. I want the entire LISP file to run, not just one function? Again, thanks for your replies. This looks like it's going to work quite well if I can just get all the switches formatted correctly. Quote Link to comment Share on other sites More sharing options...
Bill Tillman Posted January 13, 2012 Author Share Posted January 13, 2012 After a few more test runs I got it working. The big button on the Excel workbook launches AutoCAD, loads the drawing file, loads and executes the VLISP file. Thanks again for all the very helpful advice. Quote Link to comment Share on other sites More sharing options...
Bill Tillman Posted January 14, 2012 Author Share Posted January 14, 2012 Yes indeed, everything worked fine, but we had a few glitches with moving it to other users computers. As usual, one user had I:\ mapped and another had J:\ mapped....etc. So we decided to use \\server_drive\folder1\folder2\folder3....etc. Some of the users had designs on burying the files extremely deep down into the directory tree. And some of the folder names had spaces in them. Which made it impossible to get the process to run smoothly. We renamed some of the directories to eliminate spaces in the paths, but this will become a problem later when we really roll this out because the folders already exist and changing names will not be allowed. I guess what I'm asking is will the \ character be needed to escape the spaces. Like on a unix machine, should I enter the path as \\server\ drive\\folder\ 1\\folder\ 2? And then of course there is the first part of the path which has two \\ in it to begin with. We tried three and then four \ to escape the other \\ but nothing worked. We ended up renaming some of the folders to eliminate spaces and then used drive mappings. Like I said this will be forgiven for the moment but eventually I will have to comply with the standards from the IT guys which are not really standards when you think about it. Quote Link to comment Share on other sites More sharing options...
Dadgad Posted January 14, 2012 Share Posted January 14, 2012 After a few more test runs I got it working. The big button on the Excel workbook launches AutoCAD, loads the drawing file, loads and executes the VLISP file. Thanks again for all the very helpful advice. Winning!!!! Bill Rules. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 14, 2012 Share Posted January 14, 2012 Winning!!!! Quote Link to comment Share on other sites More sharing options...
Bill Tillman Posted January 15, 2012 Author Share Posted January 15, 2012 Yo bros....I be bangin seven ho's at a time...! Winnin'.....Winnin'......Winnin' Wonder if Charlie Sheen can do VLISP? Quote Link to comment Share on other sites More sharing options...
Dadgad Posted January 15, 2012 Share Posted January 15, 2012 (edited) Rumor has it that towards the end of one too many brain-numbing 7g rocks, on the 3rd day of partying at about 5:00 am with his dentures out, he develops a bit of a lisp, but it borders on RUDEmental, and is plagued with erratic behavior and frequent crashes. whining! Please Bill, try to show a little respect for the afo'mentioned GODDESSES. It's my understanding that he hires freelance spread-sheet analysts, if he feels the need to validate and rectify errant datum. Claims it is cheaper that way. Whence he does not feel the need to learn VLISP, says "it's all Greek to him". Edited January 15, 2012 by Dadgad Quote Link to comment Share on other sites More sharing options...
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.