Hi, I have a bezier line with 20 points on it and I am trying to reduce this to a line with 4 points, keeping the first and last points and 2 evenly spaced points in between like so: *....................* becomes: *. . . .*
These points are removable only by index, so if I remove point 2, point 3 then becomes point 2 in the next iteration, so I end up having a spacing like this which is not what I want: *. . . .* Here is the code that I have so far. I hope it makes sense: ############################################################################################## for aNode in nuke.allNodes(): if aNode.shown(): theRotoNode = aNode curveKnob = theRotoNode['curves'] rootLayer = curveKnob.rootLayer theNumberOfPointToReduceTo = 5 for aShape in rootLayer: theOriginalShape = aShape thePointList = [] for aPoint in aShape: thePointList.append(aPoint) if len(thePointList) > 5: theNumberOfPoints = len(thePointList) keepEvery = float(theNumberOfPoints)/theNumberOfPointToReduceTo theIndicesToKeep = [] theIndicesToKeep.append(0) theIndicesToKeep.append(1) for i in range(theNumberOfPoints)[1:-1]: if i*keepEvery < theNumberOfPoints: theIndicesToKeep.append(int(round(i*keepEvery))) theIndicesToKeep.append(theNumberOfPoints-2) theIndicesToKeep.append(theNumberOfPoints-1) thePointsToRemove = tuple(set(range(theNumberOfPoints)) - set(theIndicesToKeep)) #everything is good up to here, the code below doesn't work properly and I'm kinda stuck counter = -1 for aPointIndex in thePointsToRemove: counter+=1 aPointIndex = aPointIndex-(counter) print aPointIndex aShape.remove(aPointIndex) ############################################################################################ Any advice would be greatly appreciated. Pete
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor