pmxcad Posted November 15, 2011 Posted November 15, 2011 Try Autocad Electrical. running project wide scripts (can contain commands to run LISP`s), export/import to/from excel..etc etc PMXcad Quote
lamensterms Posted December 1, 2011 Author Posted December 1, 2011 (edited) hi irneb, thanks so much for the detailed response - sorry for not getting back to you sooner...ive been flat out with so many other things that this routine had been put on the back-burner. I think ive decided how i would like to approach this, and it seems that your 'Option 2' would be the best way for me to achieve what i need. Ive done a little research into some of the VLISP functions you mentioned - and although i am quite unexperienced with VLISP... i think i have identified some of the required functions (as listed by yourself) and how to apply them. If i could please trouble you for a little help in tying it all together, that would be great. The way i understand how the procedure will operate is... a LISP file will find all the DWG files in a certain directory and compile a temporary SCR file base on the results (combing found file directories with OPEN, RUN, SAVE and CLOSE commands). This same LISP routine will then RUN the temporary SCR it has created, processing all DWGs found in the given directory. Following the steps you have detailed in your post... here are some comments and questions i have come across. 1. Somehow select or hard-code the folder path to search through (many ways this could be done). This will be hard-coded. 2. Search through this folder for "*.DWG" files. You may want to use the vl-directory-files function to obtain them. (vl-directory-files "C:\\ProStructures\\AutoCAD 2010\\Detail" "*.dwg" 1) 3. Create a temporary SCR file using open. (open "C:\\ProStructures\\AutoCAD 2010\\Detail\\_DRG Update\\DRGUtemp.scr" "W") This will create the SCR file - but not open it - is this correct? 4. For each DWG in the list obtained from vl-directory-files: This is where i get a little lost - please see comment below. 1. Write-line an open statement followed by the full pathname of the DWG file. 2. Write-line a call to load the lisp you want to run on each dwg. You may have to add a command call / defun call depending on how you wrote your lisp. 3. Write-line a QSave and Close. 5. Close the SCR file. 6. Run the temporary SCR through a call to the Script command. I am having a little trouble understanding how vl-directory-files returns the list of DWGs - and then how i can encorporate each file path into the write-line procedure. If possible - can you please advise me how to tie these steps together (in the LISP routine?), ive kinda hit a wall when comes to using the information that the vl-directory-files returns. Thanks so much for any help. Edited December 1, 2011 by lamensterms Quote
irneb Posted December 1, 2011 Posted December 1, 2011 A few comments: (3). The SCR file is created and opened as a text file for editing. So you need to save the result of the open function to a variable. Then use that variable as the file argument in write-line / princ / prin1 / print calls. When you're finished with writing all the lines into the SCR file you then use the close function to release the write-handle obtained by the open function. If you don't do this it "might" give trouble when you want to run it. (4) Say you've got 3 DWG files in the C:\ProStructure\AutoCAD 2010\Detail folder: File01.DWG, File02.DWG & File03.DWG. A call of (vl-directory-files "C:\\ProStructure\\AutoCAD 2010\\Detail" "*.dwg" 1) Will return a list which looks like this: ("File01.DWG" "File02.DWG" "File03.DWG") From that list you can loop using foreach and inside the loop write-line the needed to the SCR file. E.g. (defun c:RunScript (/ path run scr file dwg-list) (setq path "C:\\ProStructure\\AutoCAD 2010\\Detail" run "(load \"C:\\MyLisps\\CleanUp.LSP\")" scr "C:\\ProStructures\\AutoCAD 2010\\Detail\\_DRG Update\\DRGUtemp.scr" ) (if (setq file (open scr "w")) (progn (setq dwg-list (vl-directory-files path "*.dwg" 1)) (foreach dwg dwg-list (write-line (strcat "OPEN \"" path "\\" dwg "\"") file) (write-line run file) (write-line "QSAVE" file) (write-line "CLOSE" file) ) (close file) (command "._SCRIPT" scr) ) ) (princ) ) Note I've not tested it, but the basic ideas are there. And there's very little error trapping in that, e.g. what happens if one of the DWG's is read-only? Or if the LSP file could not be found? 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.