- 积分
- 29010
- 明经币
- 个
- 注册时间
- 2013-1-25
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2022-5-5 01:08:38
|
显示全部楼层
本帖最后由 尘缘一生 于 2022-5-5 01:23 编辑
速度问题,就是用的COMMAND 原因,抛弃command 程序会写很长,本坛有部分代码,我整合过,整理下,并没有解决速度问题。
http://bbs.mjtd.com/thread-185383-1-1.html
- ;选择集交点断开 modify by 尘缘一生 QQ:15290049
- ;;两实体(en1 en2) 为实体名 -------交点------(一级)----------------
- ;;k:(0--不延伸,1--延伸基本对象,2--延伸参数传递的对象,3--延伸)
- (defun sl-Curveinters (en1 en2 k / pl pts)
- (setq pl (vlax-invoke (vlax-ename->vla-object en1) 'IntersectWith (vlax-ename->vla-object en2) k))
- (while pl
- (setq pts (append pts (list (list (car pl) (cadr pl) (caddr pl))))
- pl (cdr (cdr (cdr pl)))
- )
- )
- pts
- )
- ;;实体与其交点打断--------(一级)------------
- (defun break_obj (ent brkptlst / brkobjlst en tp maxparam closedobj minparam obj obj2break p1param p2 p2param)
- (setq obj2break ent brkobjlst (list ent) tp (cdr (assoc 0 (entget ent))))
- (foreach brkpt brkptlst
- (if brkobjlst
- (progn
- (if (not (numberp (vl-catch-all-apply 'vlax-curve-getdistatpoint (list obj2break brkpt))))
- (foreach obj brkobjlst
- (if (numberp (vl-catch-all-apply 'vlax-curve-getdistatpoint (list obj brkpt)))
- (setq obj2break obj)
- )
- )
- )
- )
- )
- ;;---------------------------------
- (cond
- ((and (= "SPLINE" tp)
- (vlax-curve-isclosed obj2break))
- (setq p1param (vlax-curve-getparamatpoint obj2break brkpt)
- p2 (vlax-curve-getpointatparam obj2break (+ p1param 0.000001))
- )
- (command "._break" obj2break (trans brkpt 0 1) (trans p2 0 1))
- )
- ((= "CIRCLE" tp)
- (setq p1param (vlax-curve-getparamatpoint obj2break brkpt)
- p2 (vlax-curve-getpointatparam obj2break (+ p1param 0.000001))
- )
- (command "._break" obj2break (trans brkpt 0 1) (trans p2 0 1))
- (setq tp "ARC")
- )
- ((and (= "ELLIPSE" tp) (vlax-curve-isclosed obj2break))
- (setq p1param (vlax-curve-getparamatpoint obj2break brkpt)
- p2param (+ p1param 0.000001)
- minparam (min p1param p2param)
- maxparam (max p1param p2param)
- obj (vlax-ename->vla-object obj2break)
- )
- (vlax-put obj 'startparameter maxparam)
- (vlax-put obj 'endparameter (+ minparam 2pi))
- )
- (t
- (setq closedobj (vlax-curve-isclosed obj2break))
- (command "._break" obj2break (trans brkpt 0 1) (trans brkpt 0 1))
- (if (not closedobj)
- (setq brkobjlst (cons (entlast) brkobjlst))
- )
- )
- )
- )
- )
- ;;主程序------------------
- ;支持 LINE,ARC,SPLINE,LWPOLYLINE,POLYLINE,CIRCLE,ELLIPSE"
- (defun c:tr (/ ss1 ssn ssm i j k ssc ptlst ptls)
- (vl-load-com)
- (prompt "\n 支持 LINE,ARC,SPLINE,LWPOLYLINE,POLYLINE,CIRCLE,ELLIPSE")
- (setq ss1 (ssget '((0 . "LINE,ARC,SPLINE,LWPOLYLINE,POLYLINE,CIRCLE,ELLIPSE"))))
- (setq ptlst nil ptls nil ol (getvar "osmode") i -1)
- (setvar "osmode" 0)
- (while (setq ssn (ssname ss1 (setq i (1+ i))))
- (setq j 0)
- (setq ptlst nil)
- (repeat (sslength ss1)
- (setq ssm (ssname ss1 j)
- ptlst (append (sl-Curveinters ssn ssm 0) ptlst)
- j (1+ j)
- )
- )
- (setq ptls (cons ptlst ptls))
- )
- (setq ptls (reverse ptls))
- (setq k 0)
- (while (setq ssc (ssname ss1 k))
- (break_obj ssc (nth k ptls))
- (setq k (1+ k))
- )
- (setvar "osmode" 0)
- )
|
|