请教如何用Lisp生成txt文件
如题,请教各位如何实现,先谢过了 一个例子,将一个点坐标列表的内容输出到idout.txt。你可以参考一下。(defun pointout
(pointlist / f i point x y point1)
(setq f (open "idout.txt" "w"))
(setq i 0)
(repeat (length pointlist)
(setq point (nth i pointlist))
(setq x (/ (car point) 2)
y (/ (cadr point) 2)
) ;_ 结束setq
(setq x (/ (fix (* x 1e5)) 1e5)
y (/ (fix (* y 1e5)) 1e5)
) ;_ 结束setq
(princ (strcat (if (= i 0)
""
"\n"
) ;_ 结束if
(itoa (1+ i))
","
(rtos x 2 5)
","
(rtos y 2 5)
) ;_ 结束strcat
f
) ;_ 结束princ
(setq i (1+ i))
);repeat
(setq point1 (nth 0 pointlist)
x (/ (car point1) 2)
y (/ (cadr point1) 2)
) ;_ 结束setq
(setq x (/ (fix (* x 1e5)) 1e5)
y (/ (fix (* y 1e5)) 1e5)
) ;_ 结束setq
(princ (strcat "\n" (itoa 1) "," (rtos x 2 5) "," (rtos y 2 5))
f
) ;_ 结束princ
(close f)
) ;_ 结束dufun
回复 mandala 的帖子
恩,谢谢啦
本帖最后由 mandala 于 2011-4-10 22:28 编辑
输出的路径可以自己设置,如c:\\cad\\works\\或d:/works/123/。我这个lsp里选择的是默认路径。
页:
[1]