I'm working on a Revit plugin that in part accepts closed curves from Rhino that can be used to create a floor in Revit. In trying to accomodate all of the different Rhino curves that could be used I'm translating splines. The closest way to generate the spline with minimal deviation from the original has been to use NurbSpline.Create to generate the spline. I'm feeding it the control points, weights, knots, and degree from the Rhino curve and it so far works fine when the degree is set to 3 (and all other requirements met), but I've been running into an odd problem when the degree is set to 5.
The documentation says:
Degree must be 3 or greater. If rational, the control points and weights array must be the same size. There must be at least degree+1 control points. The size of knots must equal the sum of degree, the size of the controlPoints array and 1. The first degree+1 knots should be identical, as should the last degree+1 knots. The knots in the middle of the sequence must be non-decreasing.
If I feed it degree, control point, weight, and knot information such that the degree is 5 and the control point size is equal to degree + 1, the minimum 6 control points then the NurbSpline.Create method works fine. If I try to use a curve with more than degree+1 (6) control points it throws the ArgumentsInconsistentException. Reviewing all of the information shows that the size of the knots array is equal to the degree + control point size + 1, the first degree +1 knots are the same value as are the last degre +1 knots, and all of the other knot values are always non-decreasing. I've tried it on a couple of dozen splines and it looks pretty consistent.
The file has two splines that I tried to create just in a macro to test. The first spline should fail and the second spline should go through and create itself.
Hello - I asked the development team to review your case, and have some advice about what we found.
The documentation for NurbSpline.Create() is not quite accurate. Revit has a requirement that curves have C2 continuity and as a result, the collection of knots in the middle of your inputs must be increasing, not identical, to achieve this. The suggestion is therefore to adjust the knot vector to be increasing.
(Strictly speaking, the curve would still be C2 continuous for a curve with degree=5 if you had less than 4 identical knots values. In your example, you don't... But Revit is actualy enforcing that there is no multiplicity even for higher degree curves - this is because our uses of NURBS are limited to specific Revit tools like the spline sketching tool and geometry we receive from tools like AutoCAD, where this restriction offers enough for these cases. This could be relaxed in the future if it will help our partners and developers, we'd like to learn more about the use cases for these higher order curves with multiplicity.)
Our exception message in this case is incorrect regardless and we will try to improve it.
Thank you,
Scott Conover
Autodesk - Development Manager, API & Intoperability