本人借鉴了一个lisp文档,可以用于提取cad坐标生成列表。但列表格式不是本人所需的,请高人指点修改升级。lisp程序内容如下:(defun c:zb()(setvar "cmdecho" 0) (COMMAND ".UNDO" "BE")(command "-units" "2" "3" "2" "3" "" "")(setq fp (open "d:/dzb.txt" "a") s (getvar "cmdecho") n (getint "\n请输入总点数! "))
lisp程序内容如下:
(defun c:zb()
(setvar "cmdecho" 0)
(COMMAND ".UNDO" "BE")
(command "-units" "2" "3" "2" "3" "" "")
(setq fp (open "d:/dzb.txt" "a") s (getvar "cmdecho") n (getint "\n请输入总点数! "))
(princ "点号" fp)(princ "\t" fp)
(princ "X坐标值" fp)(princ "\t" fp)
(princ "Y坐标值" fp)(princ "\n" fp)
(repeat n
(setq k (getstring "\n输入点号(如:K1)!")
p (getpoint "\n选取节点!")
x (strcat "X=" (rtos (nth 0 p)))
y (strcat "Y=" (rtos (nth 1 p))))
(princ k fp)(princ "\t" fp)
(princ x fp)(princ "\t" fp)
(princ y fp)(princ "\n" fp))
(close fp)
(setvar "cmdecho" s))
(princ "\n提示:点坐标保存在 D:/dzb.txt!")
(princ)
这个程序生成的文本如下
点号 X坐标值 Y坐标值
1 X=0 Y=97.193
2 X=0 Y=105.994
3 X=103 Y=105.994
4 X=103 Y=97.193
5 X=55.049 Y=97.193
6 X=47.95 Y=97.193
而我所期望的是
1.不用输入总点数,用空格键结束命令。
2.不要有“x=” 及“Y=”这两个字符。
恳请指教修改