def create_window(wall, opening_ratio): faces = wall.Shape.Faces if not faces: return areas = [f.Area for f in faces] i = areas.index(max(areas)) pl = WorkingPlane.getPlacementFromFace(wall.Shape.Faces[i]) percent = math.sqrt(opening_ratio) height = percent * wall.Height width = percent * wall.Length # if width > height and width > 2: # window_type = 'Open 2-pane' # elif width < height and height > 2: # window_type = 'Sash 2-pane' # else: window_type = 'Fixed' win = Arch.makeWindowPreset(window_type, width=width, height=height, h1=100.0, h2=100.0, h3=100.0, w1=200.0, w2=100.0, o1=0.0, o2=100.0, placement=pl) # win.setExpression('Height', f'{percent} * {wall.Name}.Height') # win.setExpression('Width', f'{percent} * {wall.Name}.Length') win.recompute() v1 = wall.Shape.BoundBox.Center v2 = win.Shape.BoundBox.Center win.Placement.Base = v1.sub(v2) win.Hosts = [wall] win.recompute() return win