- <div class="blockcode"><blockquote>(defun c:vv (/ os s edt plst p1 p2 b cp rd)
- (setq os (getvar "osmode"))
- (setvar "osmode" 0)
- (while (not (setq s (ssget "_+.:E:S" '((0 . "lwpolyline")))))
- )
- (setq edt (entget (ssname s 0))
- plst (vertex edt)
- p1 (assoc 10 plst)
- b (cdr (assoc 42 plst))
- p2 (cdr (assoc 10 (cdr (member p1 plst))))
- )
- (if (null b)
- (progn (princ "\n选择为直线."))
- (progn (setq cp (trans (LM:bulgecentre (cdr p1) p2 b)
- (cdr (assoc 210 edt))
- 1
- )
- rd (LM:bulgeradius (cdr p1) p2 b)
- )
- (command "circle" cp 60)
- )
- )
- (princ (strcat "\n半径为:" (rtos rd 2 0)))
- (setvar "osmode" os)
- (princ)
- )
- ;;顶点/凸度
- (defun vertex (et)
- (vl-remove-if-not
- '(lambda (x)
- (or (= (car x) 10)
- (and (= (car x) 42) (not (zerop (cdr x))))
- )
- )
- et
- )
- )
- ;;半径
- ;;By Lee Mac
- (defun LM:bulgeradius (p1 p2 b)
- (/ (* (distance p1 p2) (1+ (* b b))) 4 (abs b))
- )
- ;;圆心
- ;;By Lee Mac
- (defun LM:bulgecentre (p1 p2 b)
- (polar p1
- (+ (angle p1 p2) (- (/ pi 2) (* 2 (atan b))))
- (/ (* (distance p1 p2) (1+ (* b b))) 4 b)
- )
- )
新手写的,调用了两个lee mac的函数,有其他不足之处,请指正!
|