I am getting the same ref planes endpoints returned for this method, i draw circles in plan to view where the endpoints are, if i use the bubbles i get "cant use unbound curve" and if i create sketch planes, the circles i draw in plan are identical, i would expect the perpendicular ref plane to be returned froma collector and the next one after zero index would be the next one with the origin_datum_plane is set to 1 or checked.
private static XYZ CheckForIntersection(ICollection<ReferencePlane> referencePlanes)
{
if (referencePlanes.Count < 3)
{
throw new Exception("Not enough reference planes");
}
ReferencePlane refPlane1 = referencePlanes.ElementAt(0);
ReferencePlane refPlane2 = referencePlanes.ElementAt(1);
ReferencePlane refPlane3 = referencePlanes.ElementAt(2);
Line line1;
Line line2;
Line line3;
using (Transaction t = new Transaction(Doc, "drawrp"))
{
t.Start();
Plane plan = SketchPlane.Create(Doc, refPlane1.Id).GetPlane();
line1 = Line.CreateBound(plan.Origin, plan.Origin + 1 * plan.XVec);
OperationsDraw.DrawCircle(Doc, line1.GetEndPoint(0).X, line1.GetEndPoint(0).Y, 0.5);
OperationsDraw.DrawCircle(Doc, line1.GetEndPoint(1).X, line1.GetEndPoint(1).Y, 0.5);
Plane plan2 = SketchPlane.Create(Doc, refPlane2.Id).GetPlane();
line2 = Line.CreateBound(plan2.Origin, plan2.Origin + 1 * plan2.XVec);
OperationsDraw.DrawCircle(Doc, line2.GetEndPoint(0).X, line2.GetEndPoint(0).Y, 0.75);
OperationsDraw.DrawCircle(Doc, line2.GetEndPoint(1).X, line2.GetEndPoint(1).Y, 0.75);
Plane plan3 = SketchPlane.Create(Doc, refPlane3.Id).GetPlane();
line3 = Line.CreateBound(plan3.Origin, plan3.Origin + 1 * plan3.YVec);
t.Commit();
}
IntersectionResultArray results;
SetComparisonResult result = line1.Intersect(line2, out results);
if (result == SetComparisonResult.Overlap && results != null && results.Size > 0)
{
return results.get_Item(0).XYZPoint;
}
result = line1.Intersect(line3, out results);
if (result == SetComparisonResult.Overlap && results != null && results.Size > 0)
{
return results.get_Item(0).XYZPoint;
}
result = line2.Intersect(line3, out results);
if (result == SetComparisonResult.Overlap && results != null && results.Size > 0)
{
return results.get_Item(0).XYZPoint;
}
MessageBox.Show("Intersection not found");
return null;
}