C4D - Select every other point in a spline

I've just received a request for a way to select every other point on a spline in C4D. Here's my way of doing it. The script can be found on the downloads page. Here's the code with comments:

import c4d

def main():

    op = doc.GetActiveObject() # Get the active object
    if not op: return False #If nothing is active, end the script
    #If the selected object is not a spline, end the script
    if not type(op) != c4d.Ospline: return False 

    #Get the selection object which the object uses to manage what is and isnt selected
    sel = op.GetPointS() 
    sel.DeselectAll()    #Deselect everything to begin with

    cnt = op.GetPointCount() #Get the number of points in the object
    for i in xrange(cnt):    #Loop through the point IDs
        if i%2 == 0: sel.Select(i) #If the number is odd, select the point
        #Change i%2 == 1 for selecting even numbers 
        #Change i%3 == 0 for selecting every third pont etc
    c4d.EventAdd() #Update the scene

if __name__=='__main__':
Posted on May 6, 2017 .