Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Splitting a curve in 2

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
BenoitE&A
1908 Views, 2 Replies

Splitting a curve in 2

Hi,

My problem is only 2D.

I am trying to do the following : 

- let's say I have 2 curves. I compute their intersection using curve1.Intersect(curve2, out IntersectionResultArray ira);

- Then I want to split each curve into 2 curves, one on each side of the intersection.

 

Here is the code :

Curve curve1, curve2, curve11, curve12, curve21, curve22;

curve1.Intersect(curve2, out IntersectionResultArray ira);

if(ira!=null) 

{

IntersectionResult ir = ira.get_item(0);

double param = ir.Parameter;

curve11 = curve1;

curve11.MakeBound(curve11.GetEndPointParameter(0),param);

etc...

}

 

The thing is : the code line 

double param = ir.Parameter;

systematically returns an error message (InvalidOperationException) whatever the curves are. 

I tryed on simple curves (lines) as well as arcs and the error message always occurs.

 

Any idea where this comes from? Or another simple way to deal with this?

Benoit


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
2 REPLIES 2
Message 2 of 3
JimJia
in reply to: BenoitE&A

Dear Benoit,

 

IntersectionResult.Parameter is invalid when 2 curves intersects, you need to use IntersectionResult.XYZPoint.

Please see codes below:

 

IntersectionResultArray ira = null;
XYZ intersectionPoint = null;

if(curve1.Intersect(curve2, out ira) == SetComparisonResult.Overlap)
{
intersectionPoint = ira.get_Item(0).XYZPoint;
}

double paraIntersection1 = curve1.Project(intersectionPoint).Parameter;
double paraIntersection2 = curve2.Project(intersectionPoint).Parameter;

 

Curve c11 = curve1.Clone();
c11.MakeBound(curve1.GetEndParameter(0), paraIntersection1);
Curve c12 = curve1.Clone();
c12.MakeBound(paraIntersection1, curve1.GetEndParameter(1));

Curve c21 = curve2.Clone();
c21.MakeBound(curve2.GetEndParameter(0), paraIntersection2);
Curve c22 = curve2.Clone();
c22.MakeBound(paraIntersection2, curve2.GetEndParameter(1));

 

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 3 of 3
BenoitE&A
in reply to: JimJia

Hi Jim,

Indeed that 's what I had thought in my shower this morning : if IntersectionResult.Parameter is not valid for curve intersection then I have the projection tool to get the parameters of the intersection for each curve.

Thanks for the reply.

I have a quick question : if instead of using

Curve c11 = curve1.Clone(); 

I code 

Curve c11 = curve1;

Then do the same, will it work or not?

 

Benoit

 

 


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report