Hello guys , I’m trying to extract window external surfaces , i have tried with the logic of extracting the window faces , calculating their normals , comparing their normals with wall orientation .
I thought this will keep only the external window surfaces but has extracted internal and external ones .
So I want to verify the intersection of wall external surfaces with the remaining window faces , so that to keep only external ones … but Im finding errors .
here is the python code im using to extract
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
# Input: lists of wall surfaces and window surfaces
wall_surfaces_list = IN[0] # List of lists of wall surfaces
window_faces_list = IN[1] # List of list of lists of window faces
# Function to get normal vector of a surface
def get_normal_vector(surface):
return surface.NormalAtParameter(0.5, 0.5)
# Function to check if the window surface's bounding box is contained within the wall surface's bounding box
def check_bounding_box_containment(wall_surface, window_surface):
wall_bbox = wall_surface.GetBoundingBox()
window_bbox = window_surface.GetBoundingBox()
return (wall_bbox.Min.X <= window_bbox.Min.X and
wall_bbox.Max.X >= window_bbox.Max.X and
wall_bbox.Min.Y <= window_bbox.Min.Y and
wall_bbox.Max.Y >= window_bbox.Max.Y and
wall_bbox.Min.Z <= window_bbox.Min.Z and
wall_bbox.Max.Z >= window_bbox.Max.Z)
# Check if window face has the same normal vector as a wall surface and is contained within the wall surface
matching_window_surfaces = []
print("Number of Wall Surfaces:", len(wall_surfaces_list))
print("Number of Window Faces:", len(window_faces_list))
for window_faces_group in window_faces_list:
for window_faces in window_faces_group:
for window_face in window_faces:
if isinstance(window_face, list):
continue
window_surface = window_face.SurfaceGeometry
if not isinstance(window_surface, Surface):
continue
window_normal = get_normal_vector(window_surface)
print("Window Normal:", window_normal)
for wall_surfaces in wall_surfaces_list:
for wall_surface in wall_surfaces:
if isinstance(wall_surface, list):
continue
wall_normal = get_normal_vector(wall_surface)
print("Wall Normal:", wall_normal)
if window_normal.IsAlmostEqualTo(wall_normal):
if check_bounding_box_containment(wall_surface, window_surface):
matching_window_surfaces.append(window_surface)
print("Matching Window Surface Found")
break # Stop checking further wall surfaces for this window face
else:
continue
break
# Output the list of matching window surfaces
OUT = matching_window_surfaces
can someone help please !