楼主不厚道,就这还收2个币!
我来发个简单的源码!- (defun c:tt(/ R kd ss n xyz en fn f)
- (setq dimzin (getvar "dimzin"))
- (setvar "dimzin" 0)
- (initget 7)
- (setq R (getreal " \n要输出圆心坐标的圆半径:"))
- (initget 7 "1 2 3 4 5 ")
- (setq kd (getkword "\n[等于半径<1>/小于半径<2>/小于等于半径<3>/大于半径<4>/大于等于半径<5>]<1>:"))
- (cond ((or (= kd "1") (= kd ""))
- (setq ss (ssget (list '(0 . "circle")(cons 40 R))))
- )
- ((= kd "2")
- (setq ss (ssget (list '(0 . "circle")'(-4 . "<")(cons 40 R))))
- )
- ((= kd "3")
- (setq ss (ssget (list '(0 . "circle")'(-4 . "<=")(cons 40 R))))
- )
- ((= kd "4")
- (setq ss (ssget (list '(0 . "circle")'(-4 . ">")(cons 40 R))))
- )
- ((= kd "5")
- (setq ss (ssget (list '(0 . "circle")'(-4 . ">=")(cons 40 R))))
- )
- )
-
- (if ss
- (progn
- (setq fn (getfiled "输入保存文件名" "" "csv" 1))
- (setq f (open fn "w"))
- (WRITE-LINE "序号,X横坐标,Y纵坐标,Z高程,半径" f)
- (setq n 0)
- (repeat (sslength ss)
- (setq en (ssname ss n))
- (setq n (1+ n))
- (setq xyz (cdr (assoc 10 (entget en)))
- R (cdr (assoc 40 (entget en))))
- (setq zc (strcat (itoa n) "," (rtos (car xyz) 2 3) "," (rtos (cadr xyz) 2 3) "," (rtos (caddr xyz) 2 3) "," (rtos R 2 3)))
- (WRITE-LINE zc f)
-
- )
- (close f)
- (startapp "notepad" fn)
- )
- )
- (setvar "dimzin" dimzin)
- (princ)
- )
|