ht1480 发表于 2022-7-23 11:33:00

点线输出坐标值到TXT,同时复制到系统剪切版

自己也是抄抄改改的小白,其中的函数出处不记得来自哪了,总之感谢乐于分享的前辈们
有需求的自取之
如果出错的话请先看看自己有没有E盘
(DEFUN C:44 (/ aa)
(setq aa (car(entsel "\n选择多段线: ")))
(getpt aa)
(dcfc ptlst)
(SET-CLIP-STRING wjyh1)
(princ)
)
;;获取坐标函数
(defun getpt(ss)
(setq ptlst (vl-remove-if 'not (mapcar '(lambda (x) (if (= (car x) 10) (cdr x))) (entget ss))))
)
;;把坐标值写入E盘的“坐标表值.txt”里
(defun dcfc (ptlst / wjmdz file1 n JXY1 xy X1 y1 TX1 Ty1 TXY J1 JXY JXY1)
(setq wjmdz (strcat "e:/坐标表值.txt"))
(setq file1 (open wjmdz "w"))
(setq n 0)
(setq JXY1 (strcat ""))
(repeat (length ptlst)
    (setq xy (nth n ptlst))
    (setq X1 (RTOS (cadr xy) 2 2));每一组坐标依次求出X的字符
    (setq y1 (RTOS (car xy) 2 2));每一组坐标依次求出Y的字符
    (setq TX1 (strcat X1 "\t"))
    (setq Ty1 (strcat Y1 "\n"))
    (setq TXY (strcat TX1 Ty1))
    (setq n (+ n 1))
    (setq J1 (strcat "J" (itoa n) "\t"))
    (setq JXY (strcat J1 TXY))
    (setq JXY1 (strcat JXY1 JXY))
)
(setq wjyh1 JXY1)
(write-line wjyh1 file1)
(alert wjyh1)
(princ)
(close file1)
(princ)
)
;;;功能:向系统剪贴板写入文字
(defun SET-CLIP-STRING (STR / HTML RESULT)
    (and (= (type STR) 'STR)
   (setq HTML (vlax-create-object "htmlfile"))
   (setq RESULT (vlax-invoke
      (vlax-get (vlax-get HTML 'PARENTWINDOW)
            'CLIPBOARDDATA
      )
      'SETDATA
      "Text"
      STR
          )
   )
   (vlax-release-object HTML)
    )
)

逍遥无声 发表于 2022-7-24 02:29:00

正好需要

注册 发表于 2022-7-24 09:49:00

有没有可以直接从txt坐标直接在CAD中画出轮廓封闭线---
页: [1]
查看完整版本: 点线输出坐标值到TXT,同时复制到系统剪切版