Skip to content

Commit

Permalink
fix(writer): Fix issue with skylight origin
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed May 25, 2024
1 parent 86f0426 commit 088d7a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
7 changes: 5 additions & 2 deletions honeybee_idaice/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def opening_to_idm(
opening: Union[Aperture, Door], ref_plane: Plane,
is_aperture=True, decimal_places: int = 3) -> str:
is_aperture=True, decimal_places: int = 3, angle_tolerance: float = 1.0) -> str:
"""Translate a HBJSON aperture or Door to an IDM Window.
Args:
Expand All @@ -20,12 +20,15 @@ def opening_to_idm(
Door. (Default: True).
decimal_places: An integer for the number of decimal places to which
coordinate values will be rounded. (Default: 3).
angle_tolerance: The max angle in degrees that opening normal can differ
from the World Z before the opening is treated as being in the
World XY plane. (Default: 1).
"""
# get the name
name = opening.identifier

# if the aperture is horizontal, use the world XY
ang_tol = math.radians(1)
ang_tol = math.radians(angle_tolerance)
vertical = Vector3D(0, 0, 1)
vert_ang = ref_plane.n.angle(vertical)
if vert_ang <= ang_tol or vert_ang >= math.pi - ang_tol:
Expand Down
21 changes: 12 additions & 9 deletions honeybee_idaice/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import List, Tuple

from ladybug_geometry.bounding import bounding_box
from ladybug_geometry.geometry3d import Point3D, Face3D
from ladybug_geometry.geometry3d import Vector3D, Point3D, Plane, Face3D
from honeybee.model import Model, Room
from honeybee.facetype import RoofCeiling, Wall, Floor, AirBoundary, get_type_from_normal

Expand Down Expand Up @@ -93,13 +93,17 @@ def ceilings_to_idm(
for vv in contours for v in vv
)

# add apertures
ref_plane = face_reference_plane(face, angle_tolerance) \
if face.has_sub_faces else None
# add apertures and doors
windows = ['']
for aperture in face.apertures:
windows.append(opening_to_idm(aperture, ref_plane, decimal_places=dpl))

if face.has_sub_faces:
if angle_tolerance < face.tilt < 180 - angle_tolerance:
ref_plane = face_reference_plane(face, angle_tolerance)
else:
ref_plane = Plane(n=Vector3D(0, 0, 1), o=origin, x=Vector3D(1, 0, 0))
for aperture in face.apertures:
op_str = opening_to_idm(aperture, ref_plane, decimal_places=dpl,
angle_tolerance=angle_tolerance)
windows.append(op_str)
windows = ''.join(windows)

cp = f' ((ENCLOSING-ELEMENT :N "{name}" :T CEILING-PART :INDEX {-1001 - fc})\n' \
Expand Down Expand Up @@ -154,8 +158,7 @@ def room_to_idm(
horiz_boundary = hz_bounds[0]
if horiz_boundary.normal.z <= 0: # ensure upward-facing Face3D
horiz_boundary = horiz_boundary.flip()
ordered_vertices = horiz_boundary.lower_left_counter_clockwise_vertices
origin = ordered_vertices[0]
origin = horiz_boundary.min
if horiz_boundary.is_convex:
pole = horiz_boundary.center
else: # use a 1 cm tolerance for pole that will not be time consuming to compute
Expand Down

0 comments on commit 088d7a3

Please sign in to comment.