- (defun c:cx ( / center circle en ent i index l lineobj point point_01 point_02 radius ss1 sscircle ssline syh x)
- (if (setq ssline (ssget '((0 . "line"))))
- (progn
- (setq ss1 nil
- i -1
- ss1 (ssadd)
- )
- (repeat (sslength ssline)
- (setq ent (entget (setq en (ssname ssline (setq i (1+ i))))))
- (if (< (distance (cdr(assoc 10 ent)) (cdr(assoc 11 ent))) 50)
- (ssadd en ss1)
- )
- )
- (command "select" ssline "r" ss1 "")
- (setq ssline (ssget "p"))
- (command "erase" ss1 "")
- (progn (setq syh 0)
- (vl-cmdf ".zoom" "e")
- (repeat (sslength ssLine)
- (entmod(setq LineObj(ssname ssLine syh)syh(1+ syh)
- point(entget LineObj)
- LineObj(vlax-ename->vla-object LineObj)
- Point_01(cdr(assoc 10 point))
- Point_01(list(car Point_01)(cadr Point_01)0)
- Point_02(cdr(assoc 11 point))
- Point_02(list(car Point_02)(cadr Point_02)0)
- point(subst(cons 10 Point_01)(assoc 10 point)point)
- point(subst(cons 11 Point_02)(assoc 11 point)point)))
- (if(setq ssCircle(ssget"F"(list Point_01 Point_02)'((0 . "CIRCLE"))))
- (progn (setq index 0)
- (repeat (sslength ssCircle)
- (entmod(setq Circle (entget(ssname ssCircle index))index(1+ index)
- radius(cdr(assoc 40 Circle))
- Center(vlax-curve-getClosestPointTo LineObj (cdr(assoc 10 Circle)) t)
- center(if(<(distance Point_01 Center)radius)Point_01
- (if(<(distance Point_02 Center)radius)Point_02 Center))
- circle(subst(cons 10 Center)(assoc 10 Circle)Circle)))
- )
- (setq l nil)
- (repeat (setq i (sslength ssCircle))
- (setq l (cons (cdr (assoc 10 (entget (ssname ssCircle (setq i (1- i)))))) l))
- )
- (mapcar '(lambda(x) (vl-cmdf "break" (list (ssname (ssget "c" x x '((0 . "*line"))) 0) x) x)) l)
- )))
- (vl-cmdf ".zoom" "p")
- (alert "完成!")
- )
- )
- )
- )
|