Message 1 of 5
Wall Face Bounding room
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
Wish you all a very Happy new year!
I have this extension method for Room, in which I am trying to return the face of a given wall which is defining the boundary of the room.
public static Face GetBoundingFace(this Room room, Wall wall)
{
if (room == null || wall == null)
return null;
Document doc = room.Document;
try
{
SpatialElementGeometryCalculator calculator = new SpatialElementGeometryCalculator(doc);
SpatialElementGeometryResults results = calculator.CalculateSpatialElementGeometry(room);
Solid spaceSolid = results.GetGeometry();
foreach (Face face in spaceSolid.Faces)
{
IList<SpatialElementBoundarySubface> spatialElementBoundarySubfaceList = results.GetBoundaryFaceInfo(face);
if (spatialElementBoundarySubfaceList.Count == 0)
continue;
ElementId elementId = spatialElementBoundarySubfaceList[0].SpatialBoundaryElement.HostElementId;
if (elementId == wall.Id)
{
return face;
}
}
}
catch (Exception ex)
{
// Handle or log the exception as needed
TaskDialog.Show("Error", $"Error getting bounding face: {ex.Message}");
}
return null;
}
However, I get the error saying;
The Reference of the input face is null. If the face was obtained from Element.Geometry, make sure to turn on the option 'ComputeReferences'.
Parameter name: face
What is going wrong?