Can I check why is it that when I run this code, it over-calculates the wall area such that it calculates wallarea that extends above the ceiling as shown in the picture (I only want to calculate the interior wall area of level 1 room but it extends to level 2 (as shown in the faint orange mark)?
import clr
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
doc = DocumentManager.Instance.CurrentDBDocument
rooms = UnwrapElement(IN[0])
selection = UnwrapElement(IN[1])
output = []
opt = SpatialElementBoundaryOptions(SpatialElementBoundaryLocation=SpatialElementBoundaryLocation.Finish)
calculator = SpatialElementGeometryCalculator(doc,opt)
totalroomFaceLst = []
for room in rooms:
if calculator.CanCalculateGeometry(room):
results = calculator.CalculateSpatialElementGeometry(room)
roomSolid = results.GetGeometry()
roomFaceLst = []
for face in roomSolid.Faces:
for spatialSubFace in results.GetBoundaryFaceInfo(face):
if spatialSubFace.SubfaceType != SubfaceType.Side:
continue
element = doc.GetElement(spatialSubFace.SpatialBoundaryElement.HostElementId)
if element is None:
continue
elementType = doc.GetElement(element.GetTypeId())
if isinstance(element, Wall):
if elementType.Kind == WallKind.Curtain:
continue
roomFaceLst.append(face.ToProtoType()[0])
totalroomFaceLst.append(roomFaceLst)
else:
output.append("cannot calculate element geometry")
OUT = totalroomFaceLst[selection]