本帖最后由 vitalgg 于 2022-4-24 10:12 编辑
txt文件保存至 D:\ 时间戳 .txt
代码中的我自定义函数定义在 @lisp 函数库中。
安装@lisp后,可以直接运行下面的代码。
- (defun export-pt (/ fp)
- (setq fp (open (strcat "D:/"
- (car (string:to-list (@:timestamp) "."))
- ".txt")
- "w"))
- (mapcar
- '(lambda(x)
- (setq att% (block:get-attributes x))
- (write-line
- (strcat (cdr (assoc "CNTP" att%))"," ;;名称
- (string:from-list (mapcar '@:to-string (entity:getdxf x 10))",")"," ;;坐标
- (cdr (assoc "ELEV" att%))"," ;;标高
- (cdr (assoc "DESC" att%))) ;; 描述
- fp))
- (pickset:to-list (ssget "x" '((0 . "insert")(2 . "cpoint")))) ;; 所有块图元
- )
- (close fp)
- (@:cmd "notepad" filename) ;; 用 notepad 打开生成的文件
- (princ))
|