Surprising results from Face.Intersect(face) method

Surprising results from Face.Intersect(face) method

ciganek
Enthusiast Enthusiast
7,864 Views
20 Replies
Message 1 of 21

Surprising results from Face.Intersect(face) method

ciganek
Enthusiast
Enthusiast

This has been mentioned in this post from 2016 but maybe it's worth bringing up again as 2018 hasn't resolved the issue yet.

 

As far as I can tell, the Face.Intersect(face) method always returns FaceIntersectionFaceResult.Intersecting - or I am not implementing it correctly. When I run the code below in a view with a single wall and single floor, each face to face test returns an intersection. Can someone please verify (maybe 2019)?

 

intersects.PNG

 

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

var list = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document, commandData.View.Id).WhereElementIsNotElementType().Where(e => e is Wall || e is Floor);


foreach (var f1 in list.First().get_Geometry(new Options()).OfType<Solid>().First().Faces.OfType<Face>())
{
foreach (var f2 in list.Last().get_Geometry(new Options()).OfType<Solid>().First().Faces.OfType<Face>())
{
if (f1.Intersect(f2) == FaceIntersectionFaceResult.Intersecting)
{

if (System.Windows.Forms.MessageBox.Show("Intersects", "Continue", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Cancel) return Result.Succeeded;
}
}
}

return Result.Succeeded;
}

0 Likes
Accepted solutions (1)
7,865 Views
20 Replies
Replies (20)
Message 21 of 21

ankofl
Advocate
Advocate


Hi @ciganek 

You can try this code (GitHub CustomCSG) . It finds the intersection of two PlanarFace lying in the same plane and returns a List<PlanarFace>

 

PlanarFace planarOne = null; // select your first PlanarFace
PlanarFace planarTwo = null; // select your second PlanarFace

List<PlanarFace> booleanPlanarFaces = planarOne.ExecuteBooleanOperation(planarTwo, BooleanOperationsType.Intersect);

 

Result of running CustomCSG.dll.CommandCaller by AddinManager in sample project ProjectToView.rvt 

 

ankofl_1-1707927240155.png