Message 1 of 7
How to Find if walls are intersecting at start and end points
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to see if I can calculate the exposed surface area of a set of walls, (for example a set of 4 walls in a square), and I'm running a check to see if the walls intersect at both the start and end points, since the walls are joined together.
By using the centerline xyz coordinates, i thought I could check and return a bool value if there is an intersection or not.
However, the code is constantly returning false and I'm not sure what I've done wrong. Hopefully someone here can help me see my errors?
private bool Wallintersect(ExternalCommandData commandData)
{
UIApplication uiApp = commandData.Application;
UIDocument uiDoc = uiApp.ActiveUIDocument;
Autodesk.Revit.DB.Document doc = uiDoc.Document;
// Collect all walls in the document
FilteredElementCollector wallCollector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls) .WhereElementIsNotElementType();
foreach (Wall selectedWall in wallCollector)
{
bool intersectsAtStart = false;
bool intersectsAtEnd = false;
foreach (Wall otherWall in wallCollector)
{
if (otherWall.Id != selectedWall.Id)
{
LocationCurve selectedWallCurve = selectedWall.Location as LocationCurve;
LocationCurve otherWallCurve = otherWall.Location as LocationCurve;
// Check for intersection at start point
if (selectedWallCurve.Curve.GetEndPoint(0).IsAlmostEqualTo(otherWallCurve.Curve.GetEndPoint(0)))
{
intersectsAtStart = true;
Walls.Joined0 = intersectsAtStart;
}
else
{
intersectsAtStart = false;
Walls.Joined0 = intersectsAtStart;
}
// Check for intersection at end point
if (selectedWallCurve.Curve.GetEndPoint(1).IsAlmostEqualTo(otherWallCurve.Curve.GetEndPoint(0)))
{
intersectsAtEnd = true;
Walls.Joined1 = intersectsAtEnd;
}
else
{
intersectsAtEnd = false;
Walls.Joined1 = intersectsAtEnd;
}
}
}
}
return Joined0 && Joined1;
}
}