Distribute Control points by z-axis

import Rhino
import Rhino.Geometry as rg
import scriptcontext as sc
import rhinoscriptsyntax as rs
import math
import random

sc.doc = Rhino.RhinoDoc.ActiveDoc
crv = rs.GetObject("sel crv",rs.filter.curve,True)
cps = rs.GetObjectGrips("sel control point")
cpps = rs.coercegeometry(crv).Points

def linspace(start,end,count):
    step = (end - start) / (count - 1)
    numbers = [start + i * step for i in range(count)]
    return numbers

l = len(cps)
r = range(l)
z = []
for i in r:

nz = linspace(min(z),max(z),l)
for i in r:
    index = cps[i][1]

I’m trying to write a small tool for uniformizing control points on the Z axis,
So I wrote a piece of code and it didn’t go wrong but it didn’t work either.
So I don’t know how to correct itself.

Please help me.

You are thinking too complicated:

_Distribute _Direction 0,0,0 0,0,1

Thanks, But unfortunately _Distribute does not work on control points.

It does. effect is prominent on the lower bottom of the curve

_PointsOn _SelControlPoint _Distribute _Direction 0,0,0 0,0,1

Oh,i know why,it caused by version differences, just discovered that in rhino8 _Distribute works on control points but not in rhino7.