本帖最后由 htlaser 于 2023-6-15 08:45 编辑
作者不详 忘记了- [code=lisp](defun outcurvept (en / n l ls1 ls2 lo po a b p1 p2 p11 p22)
- (setq ob (vlax-ename->vla-object en))
- (setq ls1 (list(cons 0.0(vlax-curve-getstartpoint ob))))
- (if (wcmatch (vla-get-objectname ob) "*Polyline")
- (setq n 0
- x(while ;x仅匹配setq格式用
- (setq po(vlax-curve-getpointatparam ob (setq n (1+ n))))
- (setq l (vlax-curve-getDistAtParam ob n))
- (setq ls2(append ls2(list(cons l po))));距离+坐标
- )
- )
- (setq l(vlax-curve-getDistAtParam ob (vlax-curve-getendparam ob))
- ls2(list(cons l(vlax-curve-getendpoint ob)))
- );line,spline,circle,arc,ellipse
- )
- (while
- (setq p11(last ls1) p22(car ls2))
- (setq a (car p11) b (- (car p22) a))
- (setq p1 (cdr p11) p2(cdr p22))
- (if (equal b(distance p1 p2) 1e-5);直线段不管
- (setq ls2(cdr ls2) ls1(append ls1 (list p22)))
- (setq lo (+(setq b(* b 0.5))a)
- po(vlax-curve-getPointAtDist ob lo);中间点
- x (if (< (* b 0.9999) (distance p1 po))
- (setq ls2(cdr ls2) ls1(append ls1(list p22)))
- (setq ls2 (cons(cons lo po)ls2))
- )
- )
- )
- );循环自适应
- (mapcar 'cdr ls1)
- )
[/code] |