蒹葭_Keirll 发表于 2012-12-10 19:54:06

crazylsp 发表于 2012-12-9 13:35 static/image/common/back.gif


感谢crazylsp兄,要是梁宽能记忆就更好了

蒹葭_Keirll 发表于 2012-12-10 19:57:26

本帖最后由 蒹葭_Keirll 于 2012-12-10 20:05 编辑

bdboy 发表于 2012-12-10 19:34 static/image/common/back.gif
代码应该反过来用,已有梁线实现自动断开还算有用处,虽然网上有几个但识别率不高
(defun c:trimall(/ os ss ssline n index index1 l_p1 l_p2 l_int len ent p1 p2 p3 p4 pselect a b )
(command "undo" "be")
(command "ucs" "w")
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(setq ss (ssget))
(setq index 0
      l_p1 '()
      l_p2 '()
      l_int '()
      len (sslength ss)
);end set

(repeat len ;把直线端点存入表中
    (setq ent (entget (ssname ss index))
          index (+ 1 index)
          p1 (cdr (assoc 10 ent))
          p2 (cdr (assoc 11 ent))
          l_p1 (cons p1 l_p1)
          l_p2 (cons p2 l_p2)
    );end set
);end repeat

(setq index 0
      n (length l_p1)
);end set
(repeat n
    (setq p1 (nth index l_p1)
          p2 (nth index l_p2)
          index1 0
    );end set
    (repeat n ;计算某线与其他所有线的交点
      (if (/= index1 index)
      (setq p3 (nth index1 l_p1)
            p4 (nth index1 l_p2)
            index1 (+ 1 index1)
            pt (inters p1 p2 p3 p4)
            l_int (if pt (cons pt l_int) l_int)
      );end set
      (setq index1 (+ 1 index1))
      );end if
    );end repeat
    (if (= (car p1) (car p2)) ;排序
      (setq l_int (vl-sort l_int (function (lambda (e1 e2)(< (cadr e1) (cadr e2)))) ))
      (setq l_int (vl-sort l_int (function (lambda (e1 e2)(< (car e1) (car e2)))) ))
    );end if
    (setq
          pselect p1
          b pselect
    );end set
    (setq i 0
          len (length l_int)
    );end set
    (while (< i len) ;打断
      (setq
            pselect b
            a (nth i l_int);a<b
            b (nth (+ i 1) l_int)
            pselect (list (/ (+ (car pselect) (car a)) 2.0) (/ (+ (cadr pselect) (cadr a)) 2.0))
      );end set
      (setq ssline (nentselp pselect))
      (command "break" ssline "f" a b);break之后已经不是ssline了
      (setq i (+ i 2))
    );end while
    (setq l_int '()
          index (+ 1 index)
    );end set
);end repeat
(setvar "osmode" os)
(command "ucs" "p")
(command "undo" "e")
);end fun
其实这个代码是在 已有梁线自动断开的代码 基础上做出来的,程序前半段是画梁线并把画出来的梁线作为一个选择集,后半段是实现梁线的自动断开。 梁线自动断开的单独程序可以是这个样子的,识别率可能也不会太高,若有高手看到,请指正。

bdboy 发表于 2012-12-10 20:18:48

谢谢楼上的,但实际测试了下,还是不行,有些整条线都被误删了

bdboy 发表于 2012-12-10 20:23:49

本帖最后由 bdboy 于 2012-12-10 20:26 编辑

裁剪效果如下,单独对某个交点裁剪可以,但批量裁剪就会出下面的错误

bdboy 发表于 2012-12-10 20:29:48

再就是十字交叉单独裁剪可以,T型交叉不行

xyp1964 发表于 2012-12-10 22:18:33

;; 对话框方式+动态捕捉

蒹葭_Keirll 发表于 2012-12-10 22:47:48

xyp1964 发表于 2012-12-10 22:18 static/image/common/back.gif
;; 对话框方式+动态捕捉

很厉害的程序。请问院长grread函数下的捕捉是如何实现的,除了用G版的函数还有其他方法吗?

crazylsp 发表于 2012-12-11 12:15:25

哈哈经过一天研究出对应十字交叉的修剪了!

200853006 发表于 2013-4-9 08:40:56

血学习学习,!

enn09 发表于 2014-4-21 16:52:06

最后那个不错,很实用,就需要断开的命令
页: 1 [2] 3
查看完整版本: 一个实现梁交线自动断开的程序,非实用(源码)