我需要打印200多个位于多个位置的图形,但每个图形中只有一部分以前没有由视图或公共坐标定义。。。我想要的是一个批量打印过程,可以在每个绘图处暂停以接受用户输入。我偶然发现了一堆可以工作的代码!作为一个新手程序员,我希望有人会告诉我有一个更简单的方法!
为了让它正常工作,我必须插入一个脚本文件以供用户输入。由于这无法完成,我在两个LISP中创建了两个独立的脚本,它们将无限循环。。我必须创建一个包含所有要打开的图形的txt文件。这在excell中很容易完成。此列表的目的是“读取行”并写入脚本文件。然后,脚本文件将包含一行。“OPEN”“file”“custom command”希望在我发布代码时有意义。主列表每次都要修改,所以第一行总是“下一行”,所以我用VBA删除了第一行。这一切都是在SDI=1的情况下完成的,所以我不必担心在结束时编码。。
好的,这里什么都没有。。。
设置SDI=1
主启动程序。此时必须打开第一个图形,主列表将包含上的图形2。
- ;BATCH PRINT USER DEFINED VIEW
- ;JPLANERA 7/3/12
- ;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)
- (while
- (= 1
- (getvar "cmdactive")
- )
- (command 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这是一个从主列表读取、写入脚本文件并擦除主列表第一行的例程。。。
- ;OPEN DRAWING SCRIPT MODIFY
- ;JPLANERA 7/3/12
- ;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)
- )
- (close MPTL)
- (setq OF (open "U:\\batchpress\\openfile.scr" "w")
- )
- (write-line L1 OF)
- (close OF)
- (startapp "wscript" ""U:\\batchpress\\deleteline.vbs"")
- (princ)
- (command "script" "U:\\batchpress\\openfile.scr")
- )
主列表txt文件的内容(当然缩短了)。用Excel完成。最后的“DVP”开始循环回第一个LISP例程。
- 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
打开图形并回调第一个命令LISP的脚本文件内容。我试图在主列表中完成这一切,但不断出现运行时错误。我怀疑是因为我试图编辑列表时正在使用它。。。解决方案是两个文件。
- OPEN M:\ENGR\Drawings\TOOLING\T18515\T18515.dwg DVP
TomRiddle 2008的DeleteLine函数
- 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)
- 'or
- 'Remove line number from text file (strFile)
- 'or
- '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
- Dim objFSO,objFile,Count,strLine,strLineCase,strNewFile
- Set objFSO=CreateObject("Scripting.FileSystemObject")
- Set objFile=objFSO.OpenTextFile(strFile,ForReading)
- Do Until objFile.AtEndOfStream
- strLine=objFile.Readline
- 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
- strNewFile=strNewFile
- Else
- strNewFile=strNewFile&strLine&vbcrlf
- End If
- Else
- strNewFile=strNewFile&strLine&vbcrlf
- End If
- Loop
- objFile.Close
- Set objFSO=CreateObject("Scripting.FileSystemObject")
- Set objFile=objFSO.OpenTextFile(strFile,ForWriting)
- objFile.Write strNewFile
- objFile.Close
- End Function
-
好吧,希望这一切都有意义。如果需要进一步解释,请告诉我。我也很高兴听到有一个更简单的方法!!我相信这可以用来做多个用户输入命令,但我想我要休息一下,然后再尝试做更多! |