hari-babu 发表于 2022-7-5 18:09:14

如何显示/读取文本f

你好
 
早上好,很高兴见到你们。
我是这里的新手,这是我的第一个帖子。
请考虑我在编写lisp例程方面的知识处于基本水平。请在这个问题上帮助我。
 
这是示例例程,我正在删除它,
请参阅下面的原始例程,
 
非常感谢。

rkmcswain 发表于 2022-7-5 18:22:26

在这一行上--->(if(findfile fn)(startapp“notepad”fn))
 
将“fn”更改为“fnm”

hari-babu 发表于 2022-7-5 18:31:42

非常感谢,先生。
 
这是我的问题的简化示例代码。
我在这里张贴的原始代码,这是不工作的。请帮忙。
其工作顺序为:
1) 准备选定图形文件夹中所有图形的列表。
2) 创建一个脚本文件以打开,运行另一个“process.lsp”,关闭列表的每个绘图。
3) 运行脚本
4) 运行时,脚本文件在同一个图形文件夹中弹出“errorlog.txt”。
 
我们现在需要看到“ERRORLOG.TXT”。
 
(defun c:sample        ()

(if (and (setq scrfile "D:\\lisp\\SCRIPT.scr") ; path of script file
   (setq dwgloc        (getfiled "\nSelect Any One DRAWING from Required Folder: " "" "dwg" )         ;full path of drawing
   )        ; End and                               
   (progn
   (setq afile (open scrfile "w"))        ;to create a text (script) file
   (foreach x (vl-directory-files (setq dir (vl-filename-directory dwgloc)) "*.dwg" 1)                        ;for each drawing file in same directory
(write-line (strcat "open " "\"" dir "\\" x " " "\" (load \"d:/lisp/process.lsp\") zoom extents (c:process) qsave close") afile) ; script line to open drawing, load process.lsp, run, save, and close drawing.
)        ; End foreach
   (close afile)
   )        ; End progn
   (princ "\n<!> File Selection Error <!>")
)        ; End if
(command "script" scrfile)                ; run the script file

;===============================================================;
;        until here everything is working fine.                        ;
;        Here in the back ground this script file creates                ;
;        an ERRORLOG.TXT in the same folder of drawings dwgloc        ;
;===============================================================;

(setq lg (strlen dwgloc) lg1 (- lg 10) dwgpath (substr dwgloc 1 lg1))        ;strips off drawing name (10 characters), retains only path in the string dwgloc
(setq fn (strcat dwgpath "Errorlog.txt"))        ;this is the location of error.log.txt which was created by running script file

(if (setq ff (findfile fn)) (startapp "notepad" fn)) ;ff returning nil, i dont know why???

)

hari-babu 发表于 2022-7-5 18:37:50

运行上述程序后,如果我键入命令提示符
 
(setq ff(findfile fn))
(startapp“notepad”fn)
 
它工作正常,并显示错误日志。屏幕上的txt。
但是我不想做那种体力劳动。我需要我的程序弹出错误日志。txt文件

BIGAL 发表于 2022-7-5 18:50:16

脚本的最后一行可以是打开另一个程序(如记事本)并显示错误文件。
 
使用记事本查看(startapp“notepad”c:\\alan\\test.txt)

hari-babu 发表于 2022-7-5 18:54:19

 
就连我也这么做了。在这里,我粘贴它生成的脚本文件。但它不起作用。
注意:在发出“sample”命令后,如果我通过手动选择从命令提示符运行这个脚本,它就可以工作了。
 
open "D:\test\Newfolder\09-210.dwg " (load "d:/lisp/process.lsp") zoom extents (c:process) qsave close
open "D:\test\Newfolder\09-211.dwg " (load "d:/lisp/process.lsp") zoom extents (c:process) qsave close
open "D:\test\Newfolder\09-701.dwg " (load "d:/lisp/process.lsp") zoom extents (c:process) qsave close
open "D:\test\Newfolder\09-702.dwg " (load "d:/lisp/process.lsp") zoom extents (c:process) qsave close
open "D:\test\Newfolder\09-703.dwg " (load "d:/lisp/process.lsp") zoom extents (c:process) qsave close
open "D:\test\Newfolder\10-102.dwg " (load "d:/lisp/process.lsp") zoom extents (c:process) qsave close
open "D:\test\Newfolder\12-201.dwg " (load "d:/lisp/process.lsp") zoom extents (c:process) qsave close
delay 3000
(startapp "notepad" "D:\test\Newfolder\ERRORLOG.txt")

hanhphuc 发表于 2022-7-5 19:03:07

嗨,2条建议,不确定是否有效?试试看。。
1.将“\”改为“/”?
 
2.3000延迟后添加脚本
shell start "notepad" "D:\test\Newfolder\ERRORLOG.txt"
 
祝你好运

BIGAL 发表于 2022-7-5 19:09:50

Try(startapp“notepad”D:\\test\\Newfolder\\ERRORLOG.txt)
页: [1]
查看完整版本: 如何显示/读取文本f