I wrote a code to distribute point along a defined range in a curve. i want the points to be distributed evenly.
i tried to divide the distance between the start and end parameters by 90% percent of it,
i did it because i wanted my routine to be scalable and fit all curve lengths.
points are not evenly distributed and go beyond the end parameter.
cant figur out what is going wrong.
(defun destribute (obj strPrm endPrm / d w ppt ppts d pv x)
(setvar "osmode" 2048)
(if (setq obj (vlax-ename->vla-object obj))
(progn
(setq d (vlax-curve-getDistAtParam obj strPrm) ;_get the distance from curv start to strPrm
w (- (vlax-curve-getDistAtParam obj endPrm) d) ;_get the distance from strPrm to endPrm
x (/ w (/ (* w 90)100))) ;_divide w by 90 % of it
(setq pv strPrm)
(while (< pv endPrm) ;_while pv is smaller than endPrm
(setq pv (vlax-curve-getParamAtDist obj d)) ;_get the parameter point at d
(setq d (+ d x)) ;_add pv to list
(setq ppts (cons (vlax-curve-getPointAtParam obj pv) ppts)) ;_walk d x units as d
)
)
)
ppts
)
please help
S