There seem to be two more problems, it’s hard to tell though, since you haven’t provided any files to test the script with.
One issue, is that the
dsi variable currently still remains constant at 1 during the looping, which again causes an infinite loop! At every iteration, the surface is offset by 1 and never intersects the curve. In order to remedy this, you need to increment
dsi at the end of the while loop by a desired value (e.g. 1).
Also, in order to definitely prevent infinite loops during the development phase of your script, it is always wise to introduce some sort of counter that exits the loop at a given maximum iterations.
dsi = 1 # start offset distance
cintersectlist = None
max_count = 15 # maximum number of allowed iterations
count = 0 # current iteration count
while cintersectlist is None and count < max_count:
cintersectlist = rs.CurveSurfaceIntersection(scurvelist, cptplstart)
dsi += 1 # increment dsi by a desired value (e.g. 1)
count += 1 # increment count by 1
Furthermore, an entirely different issue might still arise. Since, surfaces are offset in their normal direction, it could be that your surface is offset in the wrong direction, and thus never intersects the curve.
If this is an issue, you can simply get a single surface normal vector and construct the vector between a surface point and its closest point on the curve. If the angle between both vectors is smaller than 90° or bigger than 270° (in radians), your surface is good to go, but if not you need to flip it, before offsetting.