Please help python code not working properly with objects

I have written code to divide the curve into short segments according to the entered quantity and approximately at a ratio of the next line equal to the previous line multiplied by the entered ratio. but the code only works properly with straight line objects. Curve objects do not work properly

<# -*- coding: utf-8 -*-
import rhinoscriptsyntax as rs

def create_points_along_curve_with_ratio(curve, ratio, num_points):
    points = []
    total_length = rs.CurveLength(curve)
    t = 1.0
    a = [t]
    for i in range(num_points-1):
        t = t * ratio 
    if ratio <= 0 or num_points <= 0:
        print("The ratio and the number of points must be greater than 0.")
        return points
    t_step = total_length / sum(a)
    t = 1.0
    for i in range(num_points):
        point = curve.PointAt(t_step * t)
        print(t_step * t)
        if i == num_points - 1:
        t = t * ratio + 1
    return points

def RunCommand():
    curve_id = rs.GetObject("Select a curve", rs.filter.curve)
    if not curve_id:
    curve = rs.coercecurve(curve_id)
    if curve is None or rs.CurveLength(curve) < rs.UnitAbsoluteTolerance():
    ratio = rs.GetReal("Enter the ratio for division (e.g., 0.5 for halves):")
    num_points = rs.GetInteger("Enter the number of points:")
    points = create_points_along_curve_with_ratio(curve, ratio, num_points)
    if points:
        for point in points:
if __name__ == "__main__":

Assigned to Scripting category.

1 Like

Everyone please help me!

Hi @theanhkc07,

To get points along a non-linear curve, use rs.CurveArcLengthPoint.

ā€“ Dale

Just what I needed. Thank you very much