I needed to print 200+ drawings located in multiple locations, but only a section of each drawing that was not previously defined by a view or common coordinates... A batch printing process that could pause at each drawing to accept user input was what i was after. I stumbled upon a bundle of code that works! As a novice coder, I am hoping someone out there will tell me there is a much easier way!
In order for this to work, I had to break in to a script file for user input. Since this cant be done, I created 2 seperate scripts within 2 LISPS that would loop infinitely.. I had to creat a txt file containing every drawing to be opened. This was done in excell fairly easily. The purpose of this list is to "read-line" and write to a script file. The script file would then contain one line. "OPEN" "file" "custom command" hopefully it makes sense as I post the code. The master list had to be modified everytime so that the first line is always "next" so I used VBA to delete the first line. This was all done with SDI=1 so i didnt have to worry about coding in a close..
Ok, here goes nothin...
Main start program. The first drawing must be open at this time, and the master list will contain drawings 2 on.
Contents of mos.scr
;BATCH PRINT USER DEFINED VIEW
;This routine will allow the user to define the view and will print the stored view
;Then the script callout starts the process that alters the "open" file script.
;Open the first drawing in the master list and initiate the DVP command to start.
;The master list will contain ALL but the current open drawing.
(DEFUN C:DVP ()
(command "-view" "W" "1" pause pause)
(command "-plot" "y" "model" "RICOH C5000 ENG" "Letter (8.5\" X 11\")" "i" "P" "n" "V" "1" "f" "c" "y" "monochrome.ctb" "y" "a" "n" "y" "y")
(command "script" "U:\\batchpress\\mos.scr")
MOS.LSP this is the routine that reads from the master list, writes to a script file and erases the first line of the master list...
;OPEN DRAWING SCRIPT MODIFY
;This routine will read the first line of the "master" list of drawings, then write it to a script file.
;This script file will contain only 1 line of code so autocad does not get "confused"
;A VBA routine is then used to delete the first line of the master list so that when
;this routine is run again, the first line to be read is the "next" drawing in the list.
(defun c:MOS (/ MPTL L1 OF)
(setq MPTL (open "U:\\batchpress\\masterpresstoollist.txt" "r")
(setq L1 (read-line MPTL)
(setq OF (open "U:\\batchpress\\openfile.scr" "w")
(write-line L1 OF)
(startapp "wscript" "\"U:\\batchpress\\deleteline.vbs\"")
(command "script" "U:\\batchpress\\openfile.scr")
contents of master list txt file (shortened of course). Done in excell. "DVP" at the end starts the loop back to the first LISP routine.
OPEN M:\ENGR\Drawings\TOOLING\T18516\T18516.dwg DVP
OPEN M:\ENGR\Drawings\TOOLING\T18519\T18519.dwg DVP
OPEN M:\ENGR\Drawings\TOOLING\T18530\T18530.dwg DVP
contents of script file to open drawings and call back first command LISP. I tried to do this all in the master list but kept getting runtime errors. I suspect because the list was being used while I was trying to edit it... solution was two files.
OPEN M:\ENGR\Drawings\TOOLING\T18515\T18515.dwg DVP
DeleteLine Function by TomRiddle 2008
Ok hopefully this all makes sense. If further explaing is needed please let me know. Also i would be happy to hear there is an easier way!! Im sure this could be used to do multiple user input commands but i think i am going to take a break before I try to do any more!
DeleteLine "U:\BATCHPRESS\masterpresstoollist.txt", "", 1, 0
Function DeleteLine(strFile, strKey, LineNumber, CheckCase)
'DeleteLine Function by TomRiddle 2008
'Remove line(s) containing text (strKey) from text file (strFile)
'Remove line number from text file (strFile)
'Remove line number if containing text (strKey) from text file (strFile)
'Use strFile = "c:\file.txt" (Full path to text file)
'Use strKey = "John Doe" (Lines containing this text string to be deleted)
'Use strKey = "" (To not use keyword search)
'Use LineNumber = "1" (Enter specific line number to delete)
'Use LineNumber = "0" (To ignore line numbers)
'Use CheckCase = "1" (For case sensitive search )
'Use CheckCase = "0" (To ignore upper/lower case characters)
Const ForReading=1:Const ForWriting=2
Do Until objFile.AtEndOfStream
If CheckCase=0 then strLineCase=ucase(strLine):strKey=ucase(strKey)
If LineNumber=objFile.Line-1 or LineNumber=0 then
If instr(strLine,strKey) or instr(strLineCase,strkey) or strKey="" then