Calculate the intersection of 3 reference planes of a family

Calculate the intersection of 3 reference planes of a family

Anonymous
Not applicable
716 Views
4 Replies
Message 1 of 5

Calculate the intersection of 3 reference planes of a family

Anonymous
Not applicable

Hi all,

 

I am trying to calculate the intersection of 3 reference planes of a family. Is that possible?

For now I have the reference of the three planes:

Reference refx = FamilyInstance.GetReferenceByName("pX");
Reference refy = FamilyInstance.GetReferenceByName("pY");
Reference refz = FamilyInstance.GetReferenceByName("pZ");

 

1.PNG

0 Likes
717 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

In order to be productive, you will first of all need to learn to search the Internet yourself.

 

One good place to start for all generic questions like this is Wikipedia:

 

https://en.wikipedia.org/wiki/Plane_(geometry)

 

Best regards,

 

Jeremy

 



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

0 Likes
Message 3 of 5

mastjaso
Advocate
Advocate

Hi Jeremy, I believe the issue is that Revit does not return a plane object, but a "Reference" object. I've been hunting for several hours but can seem to find no way of getting the plane object from the reference.

Message 4 of 5

FrankHolidaytoiling
Advocate
Advocate

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;
}

0 Likes
Message 5 of 5

jeremy_tammik
Alumni
Alumni

Rather belatedly, I would suggest using the Document GetElement method taking a Reference argument:

  

https://www.revitapidocs.com/2024/4d674a3e-cd18-6b3d-b1b2-247713fe3c9f.htm

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes