Trim Curve objects

Trim Curve objects

BardiaJahan
Advocate Advocate
6,471 Views
11 Replies
Message 1 of 12

Trim Curve objects

BardiaJahan
Advocate
Advocate

Hi all,

I am wondering if there is any way to break Curve objects into segments. My code gets a wall and gets the CurveLoop containing its edges. Then I want to offset Curves by a different distances. Finally to regenerate the CurveLoop, I need to make sure the curves are all connected to each other (a trim-like functionality). Any ideas?

0 Likes
Accepted solutions (2)
6,472 Views
11 Replies
Replies (11)
Message 2 of 12

jeremytammik
Autodesk
Autodesk

I see the Cureve.Createoffset method.

 

Are you intending to use that?

 

And then stitch together the new curves into a set of consecutive curves with mutual end points to create a curve loop?

 

I see no direct support for trimming.

 

You can calculate intersections and use the resulting points to shorten the offset curves.

 

If they need to be lenghtened instead of shortened, it might be harder.

 

All in all, this does not sound like a task I would try to address using the pure Revit API.

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 12

BardiaJahan
Advocate
Advocate

Jeremy, I took care of lengthening by creating unbound lines in the same direction as the curve's endpoint tangent and find their intersection. This is actually adding extra extension segments to the curveloop. However, for shortening the curves, I need some instructions.

 

Given a curve (not necessarily linear), I would like to locate a point on it (such as its intersection with another curve), and split the curve at that point. I am wondering if there is any direct API for such operation. If not any insight on the workaround?

 

The only way I could think of is to get an approximation of the curve using Curve.Tessellate method; Retrieve the points that lie on the desired segment; Analyze them and use the right Create method (either Line.Create, NurbSpline.Create, etc) to create a new curve. Any thoughts?

0 Likes
Message 4 of 12

Revitalizer
Advisor
Advisor

Hi,

 

when entering just "*intersection*" into 2017 RevitAPI.chm, there are 276 matching entries.

That's a starting point...

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 12

BardiaJahan
Advocate
Advocate

Thanks @Revitalizer. Actually, finding the intersection is not difficult at all. I am trying to find out how to trim the curves at their intersection. Either using direct API commands (which I doubt they exists) or another workaround. 

0 Likes
Message 6 of 12

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

once you have found your intersection points, you can trim the curves.

Just create new lines or arcs using the former curve end points and intersection points.

Which ones to use depends on distance values (to a given point for the side to cut).

You need to do some math.

 

For arcs to cut, you need an additional point on that arc to create the new cut arc (Arc.Create(p1,p2,p3) needs three points, Line.CreateBound(p1,p2) two).

 

Once you have the new Lines and Arcs, you can use them to replace the former DetailCurves' Locations.

Or you can create new DetailCurves and delete the source Elements.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 7 of 12

BardiaJahan
Advocate
Advocate

Thanks again, specially for elaborating. This would definitely work. Since I need to handle all different types of curves (not only lines and arcs but NurbSplines etc), do you think tessellate would work? In other words, is tessellate method a proper way to analyze NurbSpline curves since it does not have any input for tolerance?

0 Likes
Message 8 of 12

Revitalizer
Advisor
Advisor

Hi,

 

for NurbSplines, I don't think that you can modify it that easy since the math is more complex.

 

You can create a Spline that looks similar, but I don't think the user wants his original geometry getting simplified.

 

How to exactly cut a Spline - that's a question for math students.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 9 of 12

BardiaJahan
Advocate
Advocate

I totally believe in not simplifying geometry. Good problem for math gurus to think about.

0 Likes
Message 10 of 12

FAIR59
Advisor
Advisor
Accepted solution

Revit has a method to set the endpoints of a Curve: 

 

public void MakeBound(
double startParameter,
double endParameter
)

 

Parameters

startParameter
Type: System Double
The new parameter of the start point.
endParameter
Type: System Double
The new parameter of the end point.

 

So you can clone a curve and adjust the endpoints.

Message 11 of 12

Revitalizer
Advisor
Advisor

Hi,

 

so it looks as if one just needs to get the IntersectionResult.Parameter property and feed the MakeBound method with it, plus the curve's remaining end parameter.

Cannot imagine that this will function with Splines, though.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 12 of 12

BardiaJahan
Advocate
Advocate

Thanks @FAIR59, very interesting! I should give it a try but I have the same concern as @Revitalizer (about NurbSplines etc)

0 Likes