本帖最后由 xyp1964 于 2023-9-9 09:49 编辑
- (defun c:wb ()
- (defun mid (s1 / p1 p9)
- (vla-getboundingbox (vlax-ename->vla-object s1) 'p1 'p9)
- (list (vlax-safearray->list p1) (vlax-safearray->list p9))
- (mapcar '(lambda (x y) (* (+ x y) 0.5))
- (vlax-safearray->list p1)
- (vlax-safearray->list p9)
- )
- )
- "将文本及坐标导出dat文件"
- (princ "\n选择需要导出的文本")
- (if (setq ss (ssget '((0 . "text"))))
- (progn
- (setq ff (OPEN (getfiled "文件保存到" "d:/" "dat" 1) "W")
- i -1
- )
- (while (setq s1 (ssname ss (setq i (1+ i))))
- (setq nr (cdr (assoc 1 s1))
- zb (mid s1)
- x (rtos (car zb) 2 3)
- y (rtos (cadr zb) 2 3)
- z (rtos (caddr zb) 2 3)
- )
- (princ (strcat nr "," y "," x) ff)
- (princ "\n" ff)
- )
- (close ff)
- (prompt (strcat "\n共添加了" (itoa (sslength ss)) "个文本及坐标"))
- )
- )
- (princ)
- )
|