Per NurbsCurveKnotList.RemoveMultipleKnots Method,
minimumKnotMultiplicity: Remove knots with multiplicity >= minimumKnotMultiplicity.
maximumKnotMultiplicity: Remove knots with multiplicity <= maximumKnotMultiplicity.
But the method in 6.0.17227.14151, 8/15/2017 requires the arguments to be “>” and “<”, respectively.
For example, minimumKnotMultiplicity=2 and maximumKnotMultiplicity=3 should remove 3 knots, but 1 and 4, respectively, are required here:
Original knot vector: [0.0, 0.0, 0.0, 3.0, 6.0, 6.0, 9.0, 9.0, 9.0, 12.0, 12.0, 12.0]
Min:1 Max:3 Removed:1 [0.0, 0.0, 0.0, 3.0, 6.0, 9.0, 9.0, 9.0, 12.0, 12.0, 12.0]
Min:2 Max:3 Removed:0 [0.0, 0.0, 0.0, 3.0, 6.0, 6.0, 9.0, 9.0, 9.0, 12.0, 12.0, 12.0]
Min:3 Max:3 Removed:0 [0.0, 0.0, 0.0, 3.0, 6.0, 6.0, 9.0, 9.0, 9.0, 12.0, 12.0, 12.0]
Min:1 Max:4 Removed:3 [0.0, 0.0, 0.0, 3.0, 6.0, 9.0, 12.0, 12.0, 12.0]
Min:2 Max:4 Removed:2 [0.0, 0.0, 0.0, 3.0, 6.0, 6.0, 9.0, 12.0, 12.0, 12.0]
Min:3 Max:4 Removed:0 [0.0, 0.0, 0.0, 3.0, 6.0, 6.0, 9.0, 9.0, 9.0, 12.0, 12.0, 12.0]
Min:4 Max:4 Removed:0 [0.0, 0.0, 0.0, 3.0, 6.0, 6.0, 9.0, 9.0, 9.0, 12.0, 12.0, 12.0]
import Rhino
import rhinoscriptsyntax as rs
def main():
gCrv = rs.GetObject("Select curve", filter=rs.filter.curve, preselect=True)
if gCrv is None: return
rgCrv0 = rs.coercecurve(gCrv)
if not isinstance(rgCrv0, Rhino.Geometry.NurbsCurve):
rgCrv0 = rgCrv0.ToNurbsCurve()
print "Original knot vector: {}".format(
[rgCrv0.Knots[i] for i in range(rgCrv0.Knots.Count)])
for max in range(rgCrv0.Degree, rgCrv0.Degree+2):
for min in range(1, max+1):
rgCrv1 = rgCrv0.DuplicateCurve()
knots = rgCrv1.Knots
s = "Min:{} Max:{}".format(min, max)
s += " Removed:{}".format(knots.RemoveMultipleKnots(
min, max, Rhino.RhinoMath.UnsetValue))
s += " {}".format([knots[i] for i in range(knots.Count)])
print s
if __name__ == '__main__': main()
RemoveMultipleKnots.3dm (30.3 KB)
Thank you,
Steve