Split a Curve in segments as same as Curve.SplitByPoints dynamo node

Split a Curve in segments as same as Curve.SplitByPoints dynamo node

MiguelGT17
Advocate Advocate
5,033 Views
5 Replies
Message 1 of 6

Split a Curve in segments as same as Curve.SplitByPoints dynamo node

MiguelGT17
Advocate
Advocate

How is that dynamo provides a tool that split a Nurbspline curve into small segments but Revit API does not?

MiguelGT17_1-1641949075941.png

Am I wrong or do there exist some workarounds using revit API. The recommendations say it will be better if we create small segments of nurbspline instead of splitting the whole path. I do not agree as placing small nurbspline ends up with a different curve shape as you can see below:

MiguelGT17_3-1641949422431.png

red: drawing nurbspline  at small steps

dark: drawing nurbsplin interpolating between the whole points

 

Thanks in advances dear community,

Miguel G.

 

0 Likes
Accepted solutions (2)
5,034 Views
5 Replies
Replies (5)
Message 2 of 6

jeremy_tammik
Alumni
Alumni
Accepted solution

Dear Miguel,

  

Dynamo is entirely open source, so you can easily explore its inner workings yourself and see exactly how it achieves what it does.

  

That said, the Revit API does in fact provide the Tesselate method for all kinds of curves that does exactly what you are asking for:

 

https://www.revitapidocs.com/2022/f95f3199-3251-c708-c5a3-a0e9ef95ecfa.htm

 

Cheers,

  

Jeremy

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 6

RPTHOMAS108
Mentor
Mentor
Accepted solution

Splines don't divide evenly the approach I used for splines on a plane was to:

1) Measure the length of the spline

2) Construct a circle of radius: Length/Divisions

3) Place circle at end of spline

4) Find intersection between circle and spline

5) Create circle at that point

6) Find intersections between circle and spline (you get two intersection)**.

6) One will have a greater curve parameter than the other*.

7) Move circle to that point.

Repeat 6 and 7 until end encountered (single intersection for bound curve). 

 

* When you use Curve.Intersect(Curve, ResultArray). I believe the U and V of IntersectionResult.UVPoint represents the parameter of the intersection along each curve. Order of UV will depend on which curve is passed as the argument to the function.

 

** The main issue with this approach is if the division circle radius is so large or the curve so complex within the circle that the radius of the circle strikes the spline in a way that isn't a segment length from the last point. I think for that reason I tended to first split the spline up into a polyline ensuring the segment size was quite small. Then if I needed less segments I would interpolate between the two points of the polyline segment closest to the curve parameter for each division.

 

Message 4 of 6

MiguelGT17
Advocate
Advocate

Dear Jeremy, thank you for the prompt response

 

Thats a good point although I can not control the number of points that Tessellate works with. Regarding the following chapter from the building coder, I will be testing Evaluate() to make this workout.

https://thebuildingcoder.typepad.com/blog/2013/11/placing-equidistant-points-along-a-curve.html

Message 5 of 6

MiguelGT17
Advocate
Advocate

Thanks for the Guidance Thomas, I'll be testing those tips as well to get this task done.

Cheers

0 Likes
Message 6 of 6

bobythe_builder
Explorer
Explorer

any update on this @MiguelGT17 ? I'm stuck in a similar situation :(. Would appreciate your input on what workflow worked for you better. Thanks in advance. 

0 Likes