Notifications
Clear all

[Closed] Splineops not working in loop

Hi there,

does anyone know what I’m doing wrong such that

setKnotSelection theSpline 1 #(1) keep:false
setKnotSelection theSpline 2 #(1) keep:false
splineOps.fuse theSpline

works but

for i = 1 to (numKnots theSpline 1) do
(
setKnotSelection theSpline 1 #(i) keep:false
setKnotSelection theSpline 2 #(i) keep:false
splineOps.fuse theSpline

)

does not. (I have two long parallel splines, attached to create one spline object with two component splines and want to fuse the corresponding verts on each to create a single spline running along the middle between the two. – Fuse will put both points in the same place, I can then delete the extra spline)

2 Replies

nvm – I did it like this:

target = $RailSpline
sourceL = $RailSplineL
sourceR = $RailSplineR
for i = 1 to (numKnots target 1) do
(
knotLpos = getKnotPoint sourceL 1 i
knotRpos = getKnotPoint sourceR 1 i
targetPos = knotRpos + ((knotLpos – knotRpos) / 2)
setKnotPoint target 1 i targetPos

knotLInVec = getInVec sourceL 1 i
knotRInVec = getInVec sourceR 1 i
targetPos = knotRInVec + ((knotLInVec - knotRInVec) / 2)
setInVec target 1 i targetPos
    
knotLOutVec = getOutVec sourceL 1 i
knotROutVec = getOutVec sourceR 1 i
targetPos = knotROutVec + ((knotLOutVec - knotROutVec) / 2)
setOutVec target 1 i targetPos
updateShape target

)

Yes I realise this is all clunky, but hey – it works

I had a similar problem before where I was trying to weld spline verts in a loop, apparently it’s not supported.