本帖最后由 USER2128 于 2012-11-22 08:18 编辑
flytoday 发表于 2012-11-21 00:18
大侠能不输出时候前面加上序号啊,麻烦了谢谢
如前面是这样子的
1,2887794317,452867597
按你的要求加入了排序、加入了序号:
对应的“序号”标记到图形中的程序到:
http://bbs.mjtd.com/thread-99234-1-1.html
贴中的7楼下载。
- ;;; 程序设计者,USER2128,版权所有。
- ;;; 标注好的坐标输出TXT格式:
- ;;; 输出样式:
- ;;; X值 Y值
- ;;; 1, 87753.815, 52860.248
- ;;; 2, 2887765.655, 452850.981
- (defun c:tt ( / ss n info ent txt pt t_h tmp tmp1 tmp2 f_n f_op)
- (setq ss (ssget '((0 . "TEXT") (1 . "X=*,x=*"))))
- (setq n 0)
- (setq info '())
- (repeat (if ss (sslength ss) 0)
- (setq ent (entget (ssname ss n))
- txt (cdr (assoc 1 ent))
- pt (cdr (assoc 10 ent))
- t_h (cdr (assoc 40 ent))
- )
- (setq info (append info (list (list pt txt t_h))))
- (setq n (1+ n))
- )
- ; (command "_.zoom" "_e")
- (setq info (mapcar '(lambda(x)
- (progn (setq tmp (car x))
- (setq tmp1 (mapcar '(lambda(y) (- y (caddr x))) tmp)
- tmp2 (mapcar '(lambda(y) (+ y (caddr x))) tmp))
- (and (setq ss_tmp (ssget "c" tmp1 tmp2 '((0 . "TEXT") (1 . "Y=*,y=*"))))
- (setq tmp (cdr (assoc 1 (entget (ssname ss_tmp 0)))))
- (setq x (list (car x) (cadr x) tmp))
- )
- x)) info))
- (setq info (vl-sort info '(lambda (x y) (< (caar x) (caar y)))))
- (setq info (vl-sort info '(lambda (x y) (< (cadar x) (cadar y)))))
- (setq f_n (getvar "DWGname")
- f_n (strcat (substr f_n 1 (- (strlen f_n) 4)) ".txt")
- f_n (strcat (getvar "DWGPREFIX") f_n)
- )
- (setq n 0)
- (setq f_op (open f_n "w"))
- (princ " X 值 Y 值\n" f_op)
- (mapcar '(lambda(x)
- (princ (strcat (itoa (setq n (1+ n))) ", ") f_op)
- (princ (substr (cadr x) 3) f_op)
- (princ ", " f_op)
- (princ (substr (caddr x) 3) f_op)
- (princ "\n" f_op)
- ) info)
- (close f_op)
- (princ)
- )
|