Bug in SplitCurve creating 3 curves instead of two


#1

Hi,

I have a mesh and I am trying to split the outline of the mesh into two curves. This seems relatively simple using rs.splitcurve however this code:

Curves=rs.SplitCurve(Outline,(CuttingPoint1,CuttingPoint2))

(where CuttingPoint1 & CuttingPoint2 lie in the domain of Outline)

gives me 3 curves. It seems like it is splitting the curve at the two supplied cutting points as well as the seam.

Additionally, if I try to move the seam to one of the cutting points:

rs.CurveSeam(Outline,CuttingPoint1)

and then run the splitcurve as above, the curve does not split at all.

For now I am able to get around this by using the TrimCurve function twice however this seems inefficient, especially when it seems like the splitcurve function should achieve this.

Am I doing something wrong with the SplitCurve function or is this a bug?


#2

Once you have moved the curve seam to one of the split points, all you need to to is use the other parameter for a split point, although it should theoretically work with both as well… works here on my quick test…

rs.CurveSeam(Outline,CuttingPoint1)
Curves=rs.SplitCurve(Outline,CuttingPoint2)

or

Curves=rs.SplitCurve(Outline,[CuttingPoint1,CuttingPoint2])

Note: (I assume you know this) that SplitCurve() requires curve parameter(s) not 3d points. If you have points you need to convert them to parameters using rs.CurveClosestPoint(). Maybe that’s what’s not working?

HTH, --Mitch


#3

Thanks for the help Helvetosaur,

I have played around with my code and I have noticed something odd. If I run the script as is, the curve is not split however if I move the seam to CuttingPoint2 and split at CuttingPoint1 instead, the code runs as intended.

Here is part of a mesh that I am working on (its an stl in the zip):

Test Mesh.zip (384.0 KB)

and the relevant code:

Curve trim.py (894 Bytes)

It would be nice if this function ignored the seam. Maybe the help file should be updated to to include this behavior.


#4

I have run into some problems with the split curve as well. It seems like it does not work with a list of parameters for the splitting location. (All parameters are within the curve domain).

I have attached the script I am trying to execute:

import random
import rhinoscriptsyntax as rs

crvs = rs.GetObjects('pick a curve', rs.filter.curve)


for crv in crvs:
    t = 0
    tList = []
    while True:
        
        t += (random.randint(1,6) * 466)
        if t >= rs.CurveLength(crv): break
        
        tList.append(t)
    print tList
    nCrvs = rs.SplitCurve(crv, tList, True)
    
    for curve in nCrvs:
        rs.ExtrudeCurveStraight(curve, [0,0,0], [0,0,2600])