move spline knots

hello

I made a little script to distribute spline knots on z axis evenly between first and last knot.
But for the script works fine I need to apply it 100 times (100 was a high value but is a random value)
If anybody can explain why ? Thanks

--------------
undo on(
for cyc=1 to 100 do
(
aaa =$
LLL = getSegLengths aaa 1 cum: true byVertex:false
nb = LLL.count
LONGG = LLL[nb]
verts = numKnots aaa
DIFF = (getKnotPoint aaa 1 verts) - (getKnotPoint aaa 1 1)
kntb = getKnotPoint aaa 1 1
for i=2 to (verts - 1) do
(
knt = getKnotPoint aaa 1 i
pp1 = LLL[i-1]
SEC = ( DIFF.z * pp1)
setKnotPoint aaa 1 i [knt.x,knt.y,kntb.z + SEC]
)
)
updateShape aaa
)---undo

-------------------------------------

AttachmentSize
www.png10.62 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

The script works. The knots are not aligned perfectly to straight line between the first and the last. The problem is when the DIFF.z = 0. If DIFF.z is 0 the SEC variable also is 0 and the knot will not be mvoed in Z direction.
Add print or format in the script and check the DIFF.Z. .

titane357's picture

hello Miauu, happy new year

hello Miauu, happy new year !!!!
in fact if DIFF.z = 0 there is no need to use the script. :-)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.