Hello,

I am working on a python script which constrains the points of a spline. (fixed position for the first and last point, position limit for the other points). I have it working when I have a single spline.

Now my issue is when I add another spline in the same spline object, my last point is no more the last ID point but the last point of the segment starting with the point ID 0.

So what I need is to get the point ID of the last point of the segment starting with the point ID 0.

What I would need then is to get the number of points of my first segment. Can anyone help me with that? (I search the documentation but couldn't find it...)

Here is my code so far (working with a single segment spline but not working with a multi segement spline object) which stands on a python tag of the spline object:

def main() :

obj=op.GetObject()

pointCount=obj.GetPointCount()-1

#Lock base points

obj.SetPoint(0, c4d.Vector(-.5,0,-.5))

obj.SetPoint(pointCount, c4d.Vector(.5,0,-.5))

#Points constraints

for i in range(1,pointCount) :

point=obj.GetPoint(i)

if point.x<-.5:

pointX=-.5

elif point.x>.5:

pointX=.5

else:

pointX=point.x

if point.z<-.5:

pointZ=-.5

elif point.z>.5:

pointZ=.5

else:

pointZ=point.z

obj.SetPoint(i, c4d.Vector(pointX,0,pointZ))

Many thanks,

H.

Hi Mark,

Thank you for your help, it works perfect!

` `

` `

Hello Hadrien!

Here is a way counting through the segments of the spline.

Result is a array with first and last point of a segment per row.

```
seg_list = []
pnt_cnt = 0
seg_cnt = spline.GetSegmentCount()
for i in range(0, seg_cnt) :
segment = spline.GetSegment(i)
seg_list.append([pnt_cnt+i, segment["cnt"]-1+pnt_cnt+i])
pnt_cnt += segment["cnt"]-1
for row in seg_list:
print str(row[0]) + " - " + str (row[1])
```

Cheers,

Mark.