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
Solved! Go to Solution.
Solved by JimJia. Go to Solution.
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));
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
Can't find what you're looking for? Ask the community or share your knowledge.