Creating a curve that passes through given points

Creating a curve that passes through given points

Anonymous
Not applicable
4,629 Views
6 Replies
Message 1 of 7

Creating a curve that passes through given points

Anonymous
Not applicable

Hi All,

 

I have a list of points (20 points in total) and I want to create a curve that passes through these points in a Revit project. By a little bit of research I found out that there is function NurbSpline.CreateCurve(Points, Weights) that can possibly do this for me. The question is as far as I know, the Spline does not pass through the points and it passes just near the points!. Is there any class or method available that can create a model line (curve) that actually passes through the points?

And another thing, what is that pass in variable "weight" stands for?

 

Thanks for the help,

Dave

0 Likes
Accepted solutions (2)
4,630 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

So I tried another method which is pretty simple:

Hspline = HermiteSpline.Create(Points, False)

At first I thought that maybe it is not working because it was not showing me anything in the views. But when I checked the length and other properties for Hspline, they were correct! 

In order to see the curve, I placed small spheres along the curve and it seems that the curve has been created correctly but I don't know why its not been shown!

Should I create a model line and how can i do that?Points.PNG

 

0 Likes
Message 3 of 7

jeremytammik
Autodesk
Autodesk
Accepted solution

You probably need to adjust your view settings to ensure the curve is visible.

 

That has next to nothing to do with the API.

 

Explore manually through the end user interface how to set up the view correctly.

 

Once you know that, you can probably easily achieve the same programmatically though the API as well.

 

Here is a solution that cheats by using very short straight linear line segments instead of a real true smooth curve:

 

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

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 4 of 7

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

a Curve is an (invisible) object in memory, a ModelCurve or DetailCurve is an Element in the Document.

Your HermiteSpline is just a Curve.

 

See also:

 

https://forums.autodesk.com/t5/revit-api-forum/create-3d-model-curve-from-list-lt-xyz-gt-in-project-...

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 5 of 7

Anonymous
Not applicable

Thanks so much Jeremy for the response. I will Check the view properties and let you know if that was an issue.

Thanks,

Dave

 

0 Likes
Message 6 of 7

Anonymous
Not applicable

Hi Revitalizer,

The post that you sent me the link is exactly what I want to do. I will look into it and will send the result in this thread.

Thanks again,

Dave

0 Likes
Message 7 of 7

Anonymous
Not applicable

Hi All,

I just wanted to update the status on this thread:

So Previously I wasn't able to create a HermiteSpline using Revit API (it was being created but wasn't visible), it was exactly as Revitalizer mentioned, -HermiteSpline is just a curve which is not visible by itself-, but you can extract whatever you need from this curve (points on the curve, intersection of the curve with different elements, length, and ...)", in order to make it visible we have to create a model curve. Here is a simple code which does that for us (it is in Python):

 

plane = Plane.CreateByThreePoints(put three points here which are not on a straight line)

sketchplane = SketchPlane.Create(revitdocument, plane)

hspline = HermiteSpline.Create(you should put a list of points here that the hspline should cross, False)

modelcurve = revitdocument.Create.NewModelCurve(hspline, sketchplane)

 

Please note that this model curve is an Spline which is not splittable, so if you want to split it at some point, I found it easier to create different lists of points and create separate splines (if anyone has any other suggestion, that would be great.)

 

Thanks for the help Revitalizer & Jeremy.

Cheers,

Dave

 

0 Likes