大家应该知道 break_obj吧?
本帖最后由 尘缘一生 于 2023-6-12 05:11 编辑对于交点断开,已经很多了,著名的就是哪个洋鬼子写的,洋人的东西,往往很傻蛋,大批量曲线,实际上很卡,这个问题,也是难点,
那么就没有办法了吗?
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=93734&highlight=%BD%BB%B5%E3
我哪也发过一次改写的
http://bbs.mjtd.com/forum.php?mo ... hlight=%BD%BB%B5%E3
http://bbs.mjtd.com/forum.php?mo ... hlight=%BD%BB%B5%E3http://bbs.mjtd.com/forum.php?mo ... hlight=%BD%BB%B5%E3
其中这一个函数,在使用过程中,发现对于圆上的点位,进行断开是无效的,无效就无效,也不要紧,关键,它会影响你程序的继续....
那么,我改写一下子,对圆进行重写方式,完成断开
[*];圆弧--------(一级)------------
[*];图层=nil,为当前图层;颜色=nil,为当前图层颜色 ;线型比例=nil,为1
[*];(slch:arc 圆心坐标 圆半径 圆弧起点弧度 圆弧终点弧度 图层 颜色 线型比例)
[*];(slch:arc (getpoint "插入点") 40 (* pi (/ 270 180.0)) (* pi (/ 180 180.0)) "中心线" 6 5)
[*](defun slch:arc (pt r ang1 ang2 lay arccol arcbili)
[*](entmake
[*] (list
[*] '(0 . "ARC")
[*] (cons 10 pt) ;圆心坐标
[*] (cons 40 r) ;圆半径
[*] (cons 50 ang1) ;圆弧起点弧度
[*] (cons 51 ang2) ;圆弧终点弧度
[*] (if lay
[*] (cons 8 lay) ;图层
[*] (cons 8 (getvar "clayer"))
[*] )
[*] (if arccol
[*] (cons 62 arccol) ;颜色
[*] (cons 62 256)
[*] )
[*] (if arcbili
[*] (cons 48 arcbili) ;线型比例
[*] (cons 48 (* 0.01 (getvar "DIMLFAC")))
[*] )
[*] )
[*])
[*])
[*];;以某点为基点,按照角度和距离分类点集---(一级)----
[*](defun sort-by-angle-distance (ptlist pt / e1 e2 ang1 ang2)
[*](vl-sort ptlist
[*] (function
[*] (lambda (e1 e2 / ang1 ang2 )
[*] (setq ang1 (angle pt e1))
[*] (setq ang2 (angle pt e2))
[*] (if (= ang1 ang2)
[*] (< (distance pt e1) (distance pt e2))
[*] (< ang1 ang2)
[*] )
[*] )
[*] )
[*])
[*])
[*];;实体与其交点处断开--------(一级)------
[*];;enam 实体名 ptlst 实体上点集表
[*](defun break_obj (enam ptlst / os enlst p0 p1 p2 dis ly tp i maxparam minparam obj)
[*](setq os (getvar "OSMODE") tp (dxf1 enam 0))
[*](setvar "OSMODE" 0)
[*](if (= tp "CIRCLE") ;重写方式
[*] (progn
[*] (setq p0 (dxf1 enam 10) dis (dxf1 enam 40) ly (dxf1 enam 8))
[*] (setq ptlst (sort-by-angle-distance ptlst p0) i 0)
[*] (setq ptlst (cons (last ptlst) ptlst))
[*] (entdel enam)
[*] (repeat (1- (length ptlst))
[*] (setq p1 (nth i ptlst) p2 (nth (1+ i) ptlst))
[*] (slch:arc p0 dis (angle p0 p1) (angle p0 p2) ly nil nil)
[*] (setq i (1+ i))
[*] )
[*] )
[*] (progn
[*] (setq enlst (list enam))
[*] (foreach p0 ptlst
[*] (if enlst
[*] (if (not (numberp (vl-catch-all-apply 'vlax-curve-getdistatpoint (list enam p0))))
[*] (foreach obj enlst
[*] (if (numberp (vl-catch-all-apply 'vlax-curve-getdistatpoint (list obj p0)))
[*] (setq enam obj)
[*] )
[*] )
[*] )
[*] )
[*] ;;--------------------
[*] (cond
[*] ((and (= tp "SPLINE") (vlax-curve-isclosed enam))
[*] (setq
[*] p1 (vlax-curve-getparamatpoint enam p0)
[*] p2 (vlax-curve-getpointatparam enam (+ p1 0.000001))
[*] )
[*] (command "._break" enam (trans p0 0 1) (trans p2 0 1))
[*] )
[*] ((and (= tp "ELLIPSE") (vlax-curve-isclosed enam))
[*] (setq
[*] p1 (vlax-curve-getparamatpoint enam p0)
[*] p2 (+ p1 0.000001)
[*] minparam (min p1 p2)
[*] maxparam (max p1 p2)
[*] obj (en2obj enam)
[*] )
[*] (vlax-put obj 'startparameter maxparam)
[*] (vlax-put obj 'endparameter (+ minparam 2pi))
[*] )
[*] (t
[*] (command "._break" enam (trans p0 0 1) (trans p0 0 1))
[*] (if (not (vlax-curve-isclosed enam))
[*] (setq enlst (cons (entlast) enlst))
[*] )
[*] )
[*] )
[*] )
[*] )
[*])
[*](setvar "OSMODE" os)
[*])
页:
[1]