;;Set a default file name to save your data to
(setq saveFile "c:\\design.txt")
;;The following will ask the user to type a new filename to save to
;;Or if they hit enter just use the default value
(setq prompt(strcat "\nType file or hit enter to use [" saveFile "]"))
(setq input (getstring t prompt))
;;If the user has hit enter then the would like to use the default file name
;;Getstring will return "", that means there is no need to change the file name
;;Thats where the not expression comes in
(if
(not (= input ""))
(setq saveFile input)
)
最后
;;Change the original line
;;(setq file (open "c:\\design.txt" "a")) to
(setq file (open saveFile "a"))
尝试插入这些修订,但可能确实遗漏了一些内容。。。。提示如何提示用户文件保存位置。
史蒂夫 除非有办法获得一个漂亮的“另存为”对话框,否则我认为查找并将txt文件从c:\移动到任何地方都与键入完整位置一样有用。我需要移动并保存它们,但我只是不断覆盖我的主“c:\”记事本,并在制作完成后粘贴/重命名它们。 @stevesfr,你能测试一下,看看它是否像预期的那样工作吗?
(defun c:p2f (/ p x y z j ptcoord textloc cs_from cs_to file text filename)
;(setq filename (strcat "c:\\"(getstring "\nEnter File Name")".txt"))
(setq saveFile "c:\\design.txt")
(setq prompt(strcat "\nType file or hit enter to use [" saveFile "]"))
(setq input (getstring t prompt))
(if
(not (= input ""))
(setq saveFile input)
)
(setq j (getint "\nEnter Start Number"))
(while ;start while
(setq p (getpoint "Pick Point"))
(setq cs_from 1)
(setq cs_to 0)
(setq p1 (trans p cs_from cs_to 0))
(setq textloc (getpoint p "PLACE TEXT"))
(setq x (rtos (car p1)))
(setq y (rtos (cadr p1)))
(setq z (rtos (caddr P1)))
(setq ptcoord (strcat "pt"(rtos j 2 0)" "x" "y" "z))
(command "_leader" p textloc "" ptcoord "")
;(setq file (open filename "a"))
(setq file (open saveFile "a"))
;(write-line ptcoord file)
(write-line ptcoord saveFile)
;(close file)
(close saveFile)
(setq j (+ j 1))
(princ)
) ;end while
)
@kapat您应该查看Autolisp函数getfield-这将使您生成一个保存对话框 史蒂夫,你能做的就是重新做人
(setq filename (strcat "c:\\"(getstring "\nEnter File Name")".txt"))
使用:
(setq filename (strcat (getstring "\nEnter File Name")".txt"))
当您保存它时,您可以在目录中键入“c:\file1\blahblah1”
或者你可以像我一样
"c:\\"
"C:\Users\ (YOUR USERNAME) \Desktop\output file folder\"
只需在其中标记您的计算机用户名,您就可以始终拥有一个包含所有点的桌面文件夹。 亲爱的,谢谢jammie!我无法详细说明这一点,谷歌无法理解我。感谢上帝赐予人类。好人。
@杰米
这在一定程度上起作用,但是在加载并从中调用程序时,我会看到一个警报弹出式问题屏幕。。。
“分配到受保护符号:提示输入中断循环?是…否…”。。。
选择保存结果的位置,程序不重复,现在每次都会询问起始坐标位置号是多少。
我用的是2008年的 @steve你能在我发布的代码中把变量名提示符改成msg之类的东西吗,看看效果如何?我脑子有点乱,提示是Autolisp函数,所以这是autocad返回的错误消息。。。 @欢迎光临
在这些修订之前,现在合并了上述修订(解决了问题),结果不会写入我的默认保存文件。最初的程序没有出现问题。现在有了这个版本,人们每次都必须输入一个起始点编号。事情每况愈下。但是,没有删除提示弹出窗口。
页:
1
[2]