本帖最后由 wzg356 于 2020-11-27 21:47 编辑
20201127更新,小改了一点点
;采集线坐标
;直线段间不取样,曲线段按长度相似度0.9999加密取样
;;;;WZG356 by 20181129
;;适用"line,lwpolyline,polyline,spline,circle,arc,ellipse"
;对顶点拟合或样条曲线化的多线段/样条曲线也可直接取样提取实际位置坐标
;速度尚可, 曲线段万点取样耗时不大于1.5秒
;无弧段多线段取样结果与coordinates法等等正常取值结果一致,速度影响轻微
;lwpolyline,polyline,circle,arc,ellipse弧段用角度法取点速度更快,不在此例
;;示例(outcurvept (car(entsel "\n选择对象: ")))
- (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)
- )
|