yanghao1 发表于 2009-9-18 17:43:00

用AutoLisp打开当前目录下的文件,当前目录的路径,用代码如何写

<p>我这样写不对:<br/>(setq wr(open app.path + "<a href="file://\\fromlsp.txt">\\fromlsp.txt</a>" "w"))</p><p>请问,如何写。谢谢!<br/></p>

caoyin 发表于 2009-9-20 11:35:00

<p>要看什么文件!</p><p>打开当前目录(startapp "explorer.exe" (getvar "dwgprefix"))</p>

neoangelo 发表于 2010-7-27 14:17:00

学习一下~~~

AMTONNY 发表于 2010-7-27 15:19:00

<p>来一个</p>
<p><font face="Verdana">;;;;-------------<br/>;;插入文档路径<br/>(defun C:KL()<br/>(setq pt0 (getpoint "\n请指定插入位置点 :")) <br/>&nbsp;;获取当前文档路径<br/>&nbsp; ;获得support目录<br/>&nbsp;&nbsp;&nbsp; (setq path (findfile "base.dcl"))<br/>&nbsp;&nbsp;&nbsp; (setq path (substr path 1 (- (strlen path) 8)))<br/>&nbsp; ;mnl文件名<br/>&nbsp;&nbsp;&nbsp; (setq mnlpath (getvar "menuname"))<br/>&nbsp; ;当前图纸文件名<br/>&nbsp;&nbsp;&nbsp; (setq nowdwg (getvar "dwgname"))<br/>&nbsp; ;当前图纸路径<br/>&nbsp;&nbsp;&nbsp; (setq wjqm (findfile nowdwg))<br/>&nbsp; ;当前文档名<br/>&nbsp;&nbsp;&nbsp; (setq date1 (getvar "dwgname"))<br/>&nbsp; ;当前图纸所在目录</font></p>
<p><font face="Verdana">&nbsp;&nbsp;&nbsp; (setq&nbsp; date0&nbsp; (substr wjqm 1 (- (strlen wjqm) (- (strlen nowdwg) (strlen date1)))))</font></p>
<p><font face="Verdana">&nbsp;&nbsp;&nbsp; (setq date1 (getvar "dwgname"));文档名ok<br/>&nbsp; ;(setq ss (progn date0&nbsp; date1))<br/>&nbsp;&nbsp; ;(if ss<br/>&nbsp;&nbsp; (command "-text" pt0 "" 0 wjqm "")<br/>&nbsp;<br/>(princ)<br/>)<br/>;;;;;****************----***************<br/>;;;;-------------</font></p>

aicr317 发表于 2010-7-27 16:37:00

(open filename mode)

aicr317 发表于 2010-7-27 16:41:00

<p>你这样肯定不对(setq wr(open app.path + "<a href="file://fromlsp.txt/" target="_blank"><font color="#000099">\\fromlsp.txt</font></a>" "w"))</p>
<p>&nbsp;</p>
<p>应该是:(setq wr(open&nbsp;"C:\\FROMLSP.TXT" "w"))&nbsp;&nbsp; ;;假设在C盘根目录下</p>
<p>&nbsp;</p>
<p>如果路径是个变量,就你上面的APP.PATH的话,要这样写:</p>
<p>&nbsp;</p>
<p>(setq wr(open (strcat app.path "<a href="file://\\fromlsp.txt" target="_blank">\\fromlsp.txt</a>") "w"))</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>这样说还不明白的话,无奈了。。。多看书吧!</p>

zkyzzy 发表于 2010-8-22 23:37:00

<font face="Verdana">(setq txtyuan (strcat (GETVAR "DWGPREFIX") (VL-FILENAME-BASE (GETVAR "dwgname"))".txt"))</font>

zhangrunze 发表于 2024-4-28 10:07:28

命令栏输入:
显示当前文件路径:
(getvar "DWGPREFIX")
打开文件路径目录:
(startapp "explorer.exe" (getvar "dwgprefix"))
页: [1]
查看完整版本: 用AutoLisp打开当前目录下的文件,当前目录的路径,用代码如何写