本帖最后由 llsheng_73 于 2022-9-1 17:50 编辑
选择包含凸度的多段线,
不严谨的做法:遍历多段线的点p,如果它的凸度值不为0,取它的下一点及中间点,这样就有弧段起止点及中点,根据3点共圆计算圆心,
根据圆心和起止点的角度及半径加上偏移距离计算偏移后的新的起止点,用取得的凸度值画一个弧段
- (defun 3pcen(p1 p2 p3)
- (setq p1(list(/(+(car p1)(car p2))2)(/(+(cadr p1)(cadr p2))2))
- p3(list(/(+(car p2)(car p3))2)(/(+(cadr p2)(cadr p3))2)))
- (inters p1(polar p1(+(/ pi 2)(angle p1 p2))1)p3(polar p3(+(/ pi 2)(angle p3 p2))1)nil))
- (defun tt(e / en n p p1 p0 r bugle i)
- (setq en(entget e'("*"))n(vlax-curve-getendparam e)e(vlax-ename->vla-object e)i -1)
- (while(<(setq i(1+ i))n)
- (or(VL-CATCH-ALL-ERROR-P(setq p(vlax-curve-getpointatparam e i)
- bugle(VL-CATCH-ALL-APPLY'vlax-invoke-method(List e 'GetBulge i))))
- (and(/= bugle 0)
- (setq p1(vlax-curve-getpointatparam e(1+ i)))
- (setq p0(vlax-curve-getpointatparam e(+ i 0.5)))
- (setq p0(3pcen p p0 p1)r(+(distance p0 p)d))
- (entmakex(vl-remove'nil(append(mapcar'cons'(0 100 100 62 8 90 70 10 42 10)
- (list"LWPOLYLINE""AcDbEntity""AcDbPolyline"1"bmcl"2 128(polar p0(angle p0 p)r)bugle(polar p0(angle p0 p1)r)))
- (mapcar'(lambda(x)(assoc x en))'(6 8 62 370 38 -3)))))))))
- (defun c:tt(/ s e d)
- (or(setq d(getdist"偏移距离[1.0]"))(setq d 1))
- (if(setq s(ssget '((0 . "lwpolyline")(-4 . "/=")(42 . 0))))
- (while(setq e(ssname s 0))
- (ssdel e s)
- (tt e)
- )))
更严格的做法应该是:根据偏移距离先偏移整条多段线,再找出其中的弧段来重新绘制,删除偏移后的线
|