question about batch, lisp, sc
I have a compilation of .bat, .lsp, and .scr files to purge multiple drawings at one time.The problem that I have is that when it runs it opens autocad runs the routines and then closes.It then opens autocad again and does the process to the next drawing.Is there a way to perform these operations with autocad only opening once and going through all the drawings in the designated folder? another quick question.. #2I've ran into problems when calling the .bat file or .lsp, or .scr from another file directory than that which the drawings are placed in.Do these all need to be in the same folder so that they run correctly? I wrote our department a script generator that opens each drawing (path included in name) and adds the listed actions followed by a QSAVE and open the next drawing. Before that we created the file using the DOS DIR *.dwg /b > list.scr syntax and by carefully using FIND|REPLACE within excel.Obviously, this doesn't answer either of your questions and is only posted to show how clever I am.
Oh, or could be used to think of other ways around what you are doing. clever indeed.. the wheels are turning.. Are you using MDI mode?
Also check your script for close or exit.You want to close the drawing not exit autocad. oh yes, forgot to say I prefer to work in SDI mode. Some of my scripts create 1500 drawing files. I don't like the idea of having that files open in one go. I have SDI = 0 ; which i'm pretty sure allows for opening of multiple drawings.Here is what I've done starting with the batch file calling the script which purges and then loads the lisp that updates the drawing to an "update" folder.
batch file:
MD C:\PURGED
for %%f in (P:\"ACTIVE PROJECTS"\"10573 - EE - NYSE - DATACENTER SUBSTATION"\DRAWINGS\"Working Drawings"\*.dwg) do start /wait C:\"Program Files"\Autodesk\"Acade 2008"\acad.exe "%%f" /b "P:\DOCUMENTS\purge.scr"
script file:
zoom
e
-purge
a
*
n
;THIS LOADS THE TBUPDATE LISP TO SAVE THE NEW DRAWINGS IN THE DESIGNATED UPDATE FOLDER AND UNCHANGING THE ORIGINAL
(load "C:\\TBUPDATE.LSP")
TBUPDATE
QUIT
Y
lisp file:
(defun C:TBUPDATE(/ dn pa panbdn)
(setq dn (getvar "dwgname"))
(setq pa (getvar "dwgprefix"))
(setq panbdn (strcat pa "PURGED\\" dn))
(command "SAVE" panbdn)
)
I think you want to change this to be CLOSE instead. When I change it to close it runs and saves the updated folder but then it doesnt continue to the next drawings in the folder, is there a repeat command or something that I need to add into the batch file maybe?the way i had it before did it and left the originals unchanged and updated the drawings but opened autocad everytime. I'm just tryin to figure out if there is a way around that happening?The book that I'm referencing says that the quit command in a scriptresults in a different prompt than it does when in autocad directly.the prompt for script version is REALLYwant to discard all changes to drawing?, which requires the response y to quit without saving.I appreciate all your help Tim I got caught by the swapping of the responses - have a search through this forum and you will find I have highlighted it several times.
I don't know if it would help you here but I end my scripts with RESUME. This is the command you can use to continue an interupted script. If you have aat the end of a script it repeats the last completed command, sometimes with unexpected results. Ending RESUME gets around this by looking for the next command. If the next command is a series of spaces it will keep resuming until all spaces are exhausted.
Also try your script in both SDI=0 and SDI=1 mode. You do get different results.
页:
[1]
2