JPlanera 发表于 2022-7-6 07:46:56

突破???批处理过程

我需要打印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的内容。可控硅
-VIEW
RESTORE
1
QSAVE
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

 
好吧,希望这一切都有意义。如果需要进一步解释,请告诉我。我也很高兴听到有一个更简单的方法!!我相信这可以用来做多个用户输入命令,但我想我要休息一下,然后再尝试做更多!

Dadgad 发表于 2022-7-6 08:03:28

听起来你应该享受一个小小的假期,为什么不考虑去一次虚拟旅行。。。。。http://www.lee-mac.com/programs.html#general.
 
你很有可能在那里找到帮助你的东西。
 
至于停止和恢复脚本,您可能需要阅读以下内容。。。。。http://www.lukewarmcoffee.com/cad/AUGI%20-%20热情%20为每个人编写%20。pdf
 
希望你在这些链接中找到一些帮助。

BIGAL 发表于 2022-7-6 08:18:09

为什么不写一个大脚本,其中包含从主待办事项列表创建的每个dwg名称?脚本中可以有数百个打开的dwg。确保在最后关闭,只是为了实际意义,为每个dwg写一行。我认为你把事情复杂化了。您的dwg列表可以有多项选择,如,
dwg1name视图1名称
dwg1name视图2名称
dwg2name视图名
dwg3name视图名
 
open dwg1 -VIEW RESTORE 1 dvp close N
open dwg2 -VIEW RESTORE 1 dvp close N
open dwg3 -VIEW RESTORE 1 dvp close N

JPlanera 发表于 2022-7-6 08:23:24

 
我确实尝试过类似的东西,但脚本不会继续,除非我做错了什么,这是一个很大的可能性。

JPlanera 发表于 2022-7-6 08:38:17

 
非常感谢。正如比格尔所说,我肯定认为我把事情复杂化了。我对这些东西很陌生,没有受过任何训练,这是我唯一(或第一次)能想到的。我搜索了论坛,四处打听,但没有人能解决我的问题。。。我会查看链接,看看能找到什么。如果(或何时…)如果我发现了什么,我会及时报告。谢谢大家的支持!如果李无意中发现这一点,我相信他会有话要说。哈

JPlanera 发表于 2022-7-6 08:51:47

好啊这是我发现的:
 
我在李的页面上没有看到任何有帮助的内容。。但是这个链接有一些很好的信息。
 
脚本崩溃后,“恢复”命令会起作用,但您必须在每个图形中键入该命令。它简化了代码,但需要额外的击键。
 
看起来脚本跳转就是答案,看起来这就是我所做的。唯一的问题是,它只适用于1个图形。为了让“批处理”过程工作,每次都必须有一个脚本转到下一行,这是不可能的,对吗??这就是VBA从主列表中删除处理过的图形,并使用LISP将行写入SCR文件的原因。。这可能看起来过于复杂,但我找不到任何更简单的程序。如果有人能启发我,我将不胜感激!
页: [1]
查看完整版本: 突破???批处理过程