« Model and Detail Curve Colour | Main | DevLabs and Training »

January 15, 2010

Comments

Hi,

Is there a way to change the endpoints of the curves?
I've been trying to do this and have been looking for examples, but all I can find is examples of creating new curve-based elements. I'm looking for something like set_endpoints() (I know that method doesnt exist, but is there something like it?).

Thanks!

/Erik

Dear Erik,

It may seem easy to set the endpoint of a bounded line, but it is much more complex for curves in general.

Furthermore, the Revit 2011 geometry library is mainly read-only, since it only provides read access to the geometry of the Revit building model elements.

You cannot write to them directly through the geometry, since they are parametrically defined, and the geometry is only a view of them, so to speak.

So in general the answer is no, no way to change the endpoint of an existing curve, you have to create a new curve from scratch and use that instead.

Cheers, Jeremy.

Hi Jeremy

First of all, thank you for maintaing such a great blog. You and Zach Kron have been inspring me and my students with your blogs.

In your article you mentioned NURB-Spline and Hermite Spline. I guessed that these correspond to "Spline" and "Spline through points" in Revit user interface. Is this correct?

If so, Hermite Spline as mentioned in your article depends on the tangent at each control point. But Spline Through Points in Revit does not explicitly let the user control these tangents. So please can you clarify how the tangent is managed with spline-through-points.

Thanks you very much,

Dear Long Nguyen,

Thank you for your appreciation, it is a pleasure!

Zach Kron inspires and entertains me as well, very much!

The Revit API documentation states that the NurbSpline class represents a NURB spline, and the HermiteSpline class a Hermite spline, so that is not really much help.

In any case, the description above seems to match what you suggest.

Does your question refer to the user interface or the programmatic control of these objects?

Through the user interface, I have no idea whatsoever.

To control these tangents programmatically, the Hermite spline creation method NewHermiteSpline provides two overloads:

- (IList(XYZ), Boolean) creates a Hermite spline with default tangency at its endpoints.

- (IList(XYZ), Boolean, XYZ, XYZ) creates a Hermite spline with specified tangency at its endpoints.

Cheers, Jeremy.

Thank you for your (very fast) reply Jeremy.

I actually referred to the tangent in the user interface, not in the API.

One question I have heard so many people asked is how to smoothly join two spline-through-points in Revit. I know that in order to do this, we must make sure that the tangents of the two spline-through-points where they meet line up perfectly. Sadly I cannot see how to achieve this since spline-through-points in the revit user interface does not explicitly let the user control the tangents. I know that the other type of spline in the user interface (the NURBS one) does expose the tangents to the user. However, since the control points of these NURB-Spline cannot be attached to reference points, the NURB-Spline are pretty much useless in parametric design where we want to use the parameters to control the shape of the curve.

Probably I will try to look into the API to see if I can create a new class of Hermite Spline that expose the tangents in the user interface.

Hi Kean,
How to determine the Curve center between two Curves
corresponding bellow?

Arc – Arc
Circle – Arc
Elliptical arc – Ellipse
Ellipse – Ellipse
NURBS – NurbSpline
Hermite – HermiteSpline

Could you help me?

Thank and Regards,


Hi Bang,

Is this question for Jeremy or for me? :-)

Regards,

Kean

Dear Bang,

That is a nice geometrical question you have.

The Revit Geometry API does not provide direct support for that functionality, so you would have to implement it yourself, for instance by querying the two original curves for their underlying parametric definition data, calculating the input data for the curve between the two (complex!), and feeding that into the Revit API again to generate it, e.g.

http://www.coe.org/p/fo/et/thread=18887

Cheers, Jeremy.

Hi Jeremy,

http://www.coe.org/p/fo/et/thread=18887

I read it and I'll try, if you have code a specific example in Revit API with NurbSpline, HermiteSpline... I hope you share with me!

Thank and Regards,

Dear Bang,

Thank you for the interesting pointer.

It would be quite easy to implement in Revit, actually, making use of the generic parametrised curve functionality.

Just determine the two curve parameter ranges, [begin(1),end[1)] and [begin[2], end(2)]. Iterate over the two ranges simultaneously, generating points p(1,i) and p(2,i), calculate the midpaoints between them, and connect the dots.

Cheers, Jeremy.

Dear Bang,

I went and implemented my suggestion:

http://thebuildingcoder.typepad.com/blog/2013/08/generating-a-midcurve-between-two-curve-elements.html

I hope you like it.

Cheers, Jeremy.

Hello Jeremy,

I have List of points through which I want to create curve so that I can create family instance.Actually in GSA analysis software there is explicit member which is made of number of elements.Currently I am importing elements of member one by one and so these are separate instance in Revit.If I can create curve through list of points and I will be in situation to create single instance in Revit.Can you please advice me something on this?

Dear Sandeep,

It is hard for me to say anything, because you leave so many aspects open.

Especially since it sounds to me as if you are creating the family yourself on the fly.

That leaves you free to implement it in any way you see fit.

Sounds like fun.

Good luck!

Cheers, Jeremy.

Hi Jeremy!

could you tell, please, is it possible to create closed spline using Revit API.
Theoretically it is possible to do using next method:
NurbSpline Create(
IList controlPoints,
IList weights,
IList knots,
int degree,
bool closed,
bool rational)
This method has parameter closed, but when I try to create spline with points:
p1 = new XYZ(28, 4, 0.07);
p2 = (new XYZ(28, 4, 0.11);
p3 = (new XYZ(29, 4, 0.09);
p4 = (new XYZ(30, 4, 0.07);
p5 = (new XYZ(29, 4, 0.05);
p6 = (new XYZ(28, 4, 0.03);
p7 = (new XYZ(28, 4, 0.07);

Knots are next:
-0.333333; 0; 0; 0; 0.333333; 0.333333; 0.666667; 0.666667; 1.0; 1.0; 1.0;
Curve degree = 3, points are 7,
so knots count = 3 + 7 + 1 = 11.

But I'm getting error:
"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 create spline with only part of points (from p1 to p4 ) I'm getting correct result.
Does API has some special rule for closed splines?

Thank you,
Olga

Dear Olga,

Sorry this is taking so long. I am discussing the issue with the development team. Please hold on.

Cheers, Jeremy.

Dear Olga,

I heard back from the development team. They say:

We talked it over and couldn't find a valid use of closed NURBS curves in Revit proper.

The field is present, but never used. In fact, it would have been better not to expose it to the API in its current state.

We introduced the method NurbSpline.Create(controlPnts, weights) without the extra options because the rest of the parameters are never really varied in the Revit implementation.

That being said, the error reported is explaining what the method expects, specifically:

“The first degree+1 knots should be identical, as should the last degree+1 knots”

In general, the specified knot sequence doesn't make sense to us.

Assuming our closed splines are defined in the same way as open ones, we'd expect something like 0,0,0, [five evenly spaced numbers between 0 and 1], 1, 1, 1.

I hope this clarifies.

Cheers, Jeremy.

Thank you very much, Jeremy!
It's clear now.

Best regards,
Olga

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

Jeremy Tammik

AboutTopicsIndexSource