I'm working on a Revit plugin that in part accepts curves from Rhino that can be used to create a beam in Revit.
My code works well, when controlpoints of curve are greater than or equal to four. But with three control points arises a problem.
How can I draw three control points curve in Revit API?
List<XYZ> ctrPoints = new List<XYZ>();
ctrPoints.Add(new XYZ(Utils.mmToFeet(72500.017337), Utils.mmToFeet(-5072.522765), Utils.mmToFeet(0)));
ctrPoints.Add(new XYZ(Utils.mmToFeet(105082.371745), Utils.mmToFeet(-748.798009), tils.mmToFeet(0)));
ctrPoints.Add(new XYZ(Utils.mmToFeet(117899.12727), Utils.mmToFeet(-15572.997171), Utils.mmToFeet(0)));
List<double> weights = new List<double>();
weights.Add(1);
weights.Add(1);
weights.Add(1);
List<double> knots = new List<double>();
knots.Add(0);
knots.Add(0);
knots.Add(0);
knots.Add(52464.568605);
knots.Add(52464.568605);
knots.Add(52464.568605);
NurbSpline detailNurbSpline = NurbSpline.Create(ctrPoints, weights, knots, 3, false, true);
Dear Anarchyfree,
Congratulations on your interesting project!
I am glad to hear that it is working well.
Would you like to share some of it here? I am sure there would be a lot of interest in that.
To answer your question:
The exception thrown when this code is run explains that there must be at least degree + 1 control points.
Since the degree passed in is 3, this code violates that rule.
Revit’s version of creating splines is NurbSpline.Create(<<control points>>, <<weights>>).
It automatically sets the degree based on the number of points as described in this internal comment:
// Use degree 1 for two CPs, degree 2 for three CPs, and degree 3 for four or more CPs.
Best regards,
Jeremy
Thank you for your answer!
I wanted to represent a curve of 3 Control points such arch. then an error message was generated. Please see the attached pictures.