NurbsCurveKnotList.RemoveMultipleKnots return value bug

In relation to the bug fix referenced here
7.6.21127.19001, (2021-05-07),'s RemoveMultipleKnots with the tolerance parameter set to a low enough float returns the count of knots that it would remove if tolerance was set to RhinoMath.UnsetValue.

This can be demonstrated by running the following script on the curve in here:
For_NurbsCurveKnotList_RemoveMultipleKnots.3dm (22.5 KB)

Starting knot count: 25
Knots removed per RemoveMultipleKnots: 10
Ending knot count: 25
import Rhino
import rhinoscriptsyntax as rs

def main():
    gCrv = rs.GetObject("Select curve", filter=rs.filter.curve, preselect=True)
    if gCrv is None: return
    rgC = rs.coercecurve(gCrv)
    nc = rgC.ToNurbsCurve()
    print "Starting knot count: {}".format(nc.Knots.Count)
    iCt_KnotsRemoved = nc.Knots.RemoveMultipleKnots(
    print "Knots removed per RemoveMultipleKnots: {}".format(iCt_KnotsRemoved)
    print "Ending knot count: {}".format(nc.Knots.Count)

if __name__ == '__main__': main()

Thanks @spb - I’ve logged the issue.

– Dale

Thanks for reporting this should be fixed in 7.9.

While I have an actual user of this function I’d like to ask you some questions.

What are you using this for?
I understand the basic desire for a quick method to simplify a curve by removing unneeded knots. But why pick on knots of a certain multiplicity?
and why only consider removing these knots entirely instead of just reducing the multiplicity?

Do you already know something about the curves you’re applying this to? For instance they have unneeded fully multiple knots?

I am using this to simplify curves with unexpected discontinuities. For example, if I _Project a LineCurve onto a face of a single-spanned in both directions, degree 3 surface, the resultant curve may have knot multiplicities of [3,2,2,2,3]. When I then _ExtrudeCrv this curve with _SplitAtTangents=Yes, a brep with one face per span may result.

In a scenario like that described above of simplifying a degree 3 curve to be internally G2 continuous, I’m testing the results of RemoveKnotAt, RemoveKnots, and RemoveMultipleKnots and choosing the curve with the least amount of deviation from the input curve.

For higher degree curves, RemoveMultipleKnots may still be used in case its curve’s deviation is less than those modified by the other methods (with multiplicities reduced to only degree - 2).

The return code issue is fixed now.