Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NurbSpline Creation Error

3 REPLIES 3
Reply
Message 1 of 4
tlogan_lmn
905 Views, 3 Replies

NurbSpline Creation Error

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.

3 REPLIES 3
Message 2 of 4
GeomGym
in reply to: tlogan_lmn

Hi,

I've found the Revit geometry kernal has many restrictions with nurbs representations (in comparison with Rhino). even degree curves are often problematic (better to use odd anyway) and limit the number of control points to something around 30. It's quite likely that higher degree such as 5 might be problematic. It would be great if Revit overhauled nurbs and enabled non-planar and surface generation from the API.

Someone from Autodesk might be able to comment in more detail about your example.
Message 3 of 4
tlogan_lmn
in reply to: GeomGym

I was guessing it was a problem somewhere in the API, but I thought I'd throw it out there in case I was misunderstanding something and just to get it out in front of the dev team and hope it's an easy fix.
It's not a deal breaker if it doesn't work, just something that I'll have to warn people about.
Message 4 of 4
conoves
in reply to: tlogan_lmn

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

 

 



Scott Conover

Senior Engineering Manager, Revit

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community