本帖最后由 lisperado 于 2018-10-29 14:10 编辑
谢谢l顶上
但不见原版主回复所以只提供函数 ,其他用法只需自行更改参数吧!
简单思路只提供参考,原因函数返回表值并不代表曲线弯孤度所以并不精准!尤其弯度角度太大请避免!!
 - ;|
- --------------- vlax-curve-DivideBetweenPair ---------------
-
- Returns a approximate point list between two cross-section
- curves by a dividing parameter, concept of LOFT command
- ------------------------------------------------------------
- Author: lisperado
- ------------------------------------------------------------
- Arguments:
- e1,e2 - Curve entities/objects SPLINE,LWPOLYLINE etc..
- x - Direction mode 0 or 1, integer
- y - Divide parameter, integer
-
- ------------------------------------------------------------
- Returns: list of Point list (WCS)
- ------------------------------------------------------------|;
- ;;Note: NOT accurate for sharp curve
- (defun vlax-curve-DivideBetweenPair ( e1 e2 y / m i d p o l a r )
- (setq i 32.0 ;;;纵向密度用户自行设定
- a (list e1 e2)
- )
- (foreach e a
- (setq r nil
- d (vlax-curve-getdistatparam e (vlax-curve-getendparam e))
- m (/ d i)
- l 0.0
- )
- (while (and (< l d) (setq p (vlax-curve-getpointatdist e l)))
- (setq l (+ l m)
- r (cons p r)
- )
- )
- (setq o (cons (reverse r) o))
- ) ; foreach
- (setq r nil
- p '((x) (mapcar '* '(1. 1. 0.) x)) ; 转换2D
- o (mapcar '(lambda (a b) (append a (list (vlax-curve-getendpoint b)))) o (reverse a))
- )
- (foreach x (apply 'mapcar (cons '(lambda (a b) (list (setq b (p b) a (p a) ) (angle a b) (/ (distance a b) y))) o))
- (setq
- l nil
- p (car x)
- )
- (repeat (1- y)
- (setq
- p (apply 'polar (cons p (cdr x)))
- l (cons p l)
- )
- ) ; repeat
- (setq r (cons l r))
- ) ; foreach
- (apply 'mapcar (cons 'list r))
- )
;; 举例 : e1 & e2 各是曲线,平份于 5
( vlax-curve-DivideBetweenPair e1 e2 5 )
;; 返回表:
;(((113.88 294.633 0.0) (98.7727 293.563 0.0) (83.6605 292.562 0.0) (68.539 291.699 0.0) ....
;;编辑: 1. 更正: 移除多余变量 setq i 0 & setq i 1+ i
2. 暂时只支持2D因为polar函数距离参数以平面为基础
|