本帖最后由 hbgsw 于 2015-11-13 09:01 编辑
已经自己解决了,虽然写的很烂,。
- (defun c:2t (/ entss n lay ent cen x1 lst r)
- ;样条曲线线转圆弧或者圆
- (setvar "cmdecho" 0)
- (while (not (setq entss (ssget '((0 . "SPLINE"))))))
- (setq n 0
- lay "0"
- lst nil
- )
- (while (setq ent (ssname entss (setq n (1+ n))))
- (setq ent
- (mapcar
- 'cdr
- (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget ent))
- )
- ent (list (car ent) (last ent));获得两个端点
- )
- (setq
- cen (mapcar '(lambda (x) (/ x 2))
- (apply '(lambda (x1 x2) (mapcar '+ x1 x2)) ent)
- )
- )
- (setq r (/ (distance (car ent) (cadr ent)) 2))
- (setq lst (cons (list cen ent r) lst));将中心点,两端点,半径形成表
- )
- (setq lst (delsame lst 0.001));重复过滤
- (hbg_entmake_layer "MARK")
- (command "CHPROP" entss "" "la" "MARK"
- "c" "bylayer" ""
- )
- (foreach x1 lst
- (setq cen (car x1)
- r (caddr x1)
- )
- (hbg_entmake_circle lay cen r);生产新圆
- )
- (princ)
- )
- (defun delsame(l1 rcz / l2);;带容差去重(重复过的取第一次出现),有时处理坐标点需要考虑容差,函数作者:llsheng_73
- (while l1
- (setq l2(cons(car l1)l2)l1(vl-remove-if'(lambda (x)(equal(car(car l1)) (car x) rcz))(cdr l1))))
- (reverse l2))
|