美文网首页autolisp&visuallisp
autolisp 输出文本坐标清单

autolisp 输出文本坐标清单

作者: 饭桶2018 | 来源:发表于2019-05-21 16:42 被阅读0次
    
    ;Export text with X Y Position
    (defun C:exp    (/ ss str ent pt x y txt flnm fn)
      (setvar "cmdecho" 0)
      (setvar "osmode" 0)           ;设为无捕捉方式
    
      (setq ss (ssget '((0 . "TEXT"))))
      (if (not ss)
        (progn (alert " 没有选中文本")
           (exit)
        )
        (progn
          (setq str "")
          (while (> (sslength ss) 0)
            (setq ent (entget (setq en (ssname ss 0)))) ;取出第一个数据
            (setq pt  (cdr (assoc 10 ent)))
            (setq x   (car  pt))
            (setq y   (cadr pt))
            (setq txt (cdr (assoc 1 ent))) 
            (setq str (strcat str (rtos x 2 2) "\t" (rtos y 2 2) "\t" txt "\n"))        
            (setq ss  (ssdel en ss)) ; 删除第一个数据
          )
        )
      )
    
      (setq flnm (getstring "\nInput Export file name:(D:\\list.txt):"))
      (if (= (ascii flnm) 0)                    
        (setq flnm "D:\\list.txt")
      )
      (setq fn (open flnm "w"))
      (write-line str fn)
      (close fn)
      (startapp "notepad" flnm)
      (SETVAR "CMDECHO" 1)
      (princ)
    )
    
    
    

    相关文章

      网友评论

        本文标题:autolisp 输出文本坐标清单

        本文链接:https://www.haomeiwen.com/subject/vbijzqtx.html