Skip to content

Commit

Permalink
fix(create): Add secret option to turn off all rect split in Ap by Ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Jul 12, 2024
1 parent 0f66981 commit 816691c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
Binary file modified honeybee_grasshopper_core/icon/HB Apertures by Ratio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions honeybee_grasshopper_core/json/HB_Apertures_by_Ratio.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.0",
"version": "1.8.1",
"nickname": "AperturesByRatio",
"outputs": [
[
Expand Down Expand Up @@ -30,8 +30,8 @@
{
"access": "list",
"name": "_subdivide_",
"description": "Boolean to note whether to generate a single window in the\ncenter of each Face (False) or to generate a series of rectangular\nwindows using the other inputs below (True). The latter is often more\nrealistic and is important to consider for detailed daylight and\nthermal comfort simulations but the former is likely better when the\nonly concern is building energy use since energy use doesn't change\nmuch while the glazing ratio remains constant. (Default: True).",
"type": "bool",
"description": "Boolean to note whether to generate only one or two windows\nfor each Face (False) or to generate a series of repeating rectangular\nwindows using the other inputs below (True). The latter is often more\nrealistic and distributes the windows across the parent Face\nfor better daylight but the former is likely more useful when\nmodeling building energy use since energy use doesn't change\nsignifcantly while the glazing ratio remains constant. (Default: True).\n_\nNote that this input can also be the integer -1 to completely turn\noff all spltting of the base face into underling rectangles. By\ndefault, a False value here will result in two windows generated\nfor and input pentagonal gabled geometry - one rectangle and one\ntriangle. This is better for engines like EnergyPlus that cannot\nmodel windows with more than 4 vertices. However, if a single\npentagonal window is desired for such a shape, setting this\ninput to -1 will produce such a result.",
"type": "int",
"default": null
},
{
Expand Down Expand Up @@ -71,7 +71,7 @@
}
],
"subcategory": "0 :: Create",
"code": "\ntry: # import the core honeybee dependencies\n from honeybee.boundarycondition import Outdoors\n from honeybee.facetype import Wall\n from honeybee.face import Face\n from honeybee.room import Room\n from honeybee.model import Model\n from honeybee.orientation import check_matching_inputs, angles_from_num_orient, \\\n face_orient_index, inputs_by_index\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the ladybug_{{cad}} dependencies\n from ladybug_{{cad}}.config import tolerance, conversion_to_meters\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\ndef can_host_apeture(face):\n \"\"\"Test if a face is intended to host apertures (according to this component).\"\"\"\n return isinstance(face.boundary_condition, Outdoors) and \\\n isinstance(face.type, Wall)\n\n\ndef assign_apertures(face, sub, rat, hgt, sil, hor, vert, op):\n \"\"\"Assign apertures to a Face based on a set of inputs.\"\"\"\n if sub:\n face.apertures_by_ratio_rectangle(rat, hgt, sil, hor, vert, tolerance)\n else:\n face.apertures_by_ratio(rat, tolerance)\n\n # try to assign the operable property\n if op:\n for ap in face.apertures:\n ap.is_operable = op\n\n\nif all_required_inputs(ghenv.Component):\n # duplicate the initial objects\n hb_objs = [obj.duplicate() for obj in _hb_objs]\n \n # set defaults for any blank inputs\n conversion = conversion_to_meters()\n _subdivide_ = _subdivide_ if len(_subdivide_) != 0 else [True]\n _win_height_ = _win_height_ if len(_win_height_) != 0 else [2.0 / conversion]\n _sill_height_ = _sill_height_ if len(_sill_height_) != 0 else [0.8 / conversion]\n _horiz_separ_ = _horiz_separ_ if len(_horiz_separ_) != 0 else [3.0 / conversion]\n vert_separ_ = vert_separ_ if len(vert_separ_) != 0 else [0.0]\n operable_ = operable_ if len(operable_) != 0 else [False]\n\n # gather all of the inputs together\n all_inputs = [_subdivide_, _ratio, _win_height_, _sill_height_, _horiz_separ_,\n vert_separ_, operable_]\n\n # ensure matching list lengths across all values\n all_inputs, num_orient = check_matching_inputs(all_inputs)\n\n # get a list of angles used to categorize the faces\n angles = angles_from_num_orient(num_orient)\n\n # loop through the input objects and add apertures\n for obj in hb_objs:\n if isinstance(obj, Model):\n for room in obj.rooms:\n for face in room.faces:\n if can_host_apeture(face):\n orient_i = face_orient_index(face, angles)\n sub, rat, hgt, sil, hor, vert, op = \\\n inputs_by_index(orient_i, all_inputs)\n assign_apertures(face, sub, rat, hgt, sil, hor, vert, op)\n elif isinstance(obj, Room):\n for face in obj.faces:\n if can_host_apeture(face):\n orient_i = face_orient_index(face, angles)\n sub, rat, hgt, sil, hor, vert, op = inputs_by_index(orient_i, all_inputs)\n assign_apertures(face, sub, rat, hgt, sil, hor, vert, op)\n elif isinstance(obj, Face):\n if can_host_apeture(obj):\n orient_i = face_orient_index(obj, angles)\n sub, rat, hgt, sil, hor, vert, op = inputs_by_index(orient_i, all_inputs)\n assign_apertures(obj, sub, rat, hgt, sil, hor, vert, op)\n else:\n raise TypeError(\n 'Input _hb_objs must be a Model Room or Face. Not {}.'.format(type(obj)))",
"code": "\ntry: # import the core honeybee dependencies\n from honeybee.boundarycondition import Outdoors\n from honeybee.facetype import Wall\n from honeybee.face import Face\n from honeybee.room import Room\n from honeybee.model import Model\n from honeybee.orientation import check_matching_inputs, angles_from_num_orient, \\\n face_orient_index, inputs_by_index\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the ladybug_{{cad}} dependencies\n from ladybug_{{cad}}.config import tolerance, conversion_to_meters\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\ndef can_host_apeture(face):\n \"\"\"Test if a face is intended to host apertures (according to this component).\"\"\"\n return isinstance(face.boundary_condition, Outdoors) and \\\n isinstance(face.type, Wall)\n\n\ndef assign_apertures(face, sub, rat, hgt, sil, hor, vert, op):\n \"\"\"Assign apertures to a Face based on a set of inputs.\"\"\"\n if sub > 0:\n face.apertures_by_ratio_rectangle(rat, hgt, sil, hor, vert, tolerance)\n else:\n rect = True if sub == 0 else False\n face.apertures_by_ratio(rat, tolerance, rect)\n\n # try to assign the operable property\n if op:\n for ap in face.apertures:\n ap.is_operable = op\n\n\nif all_required_inputs(ghenv.Component):\n # duplicate the initial objects\n hb_objs = [obj.duplicate() for obj in _hb_objs]\n \n # set defaults for any blank inputs\n conversion = conversion_to_meters()\n _subdivide_ = _subdivide_ if len(_subdivide_) != 0 else [True]\n _win_height_ = _win_height_ if len(_win_height_) != 0 else [2.0 / conversion]\n _sill_height_ = _sill_height_ if len(_sill_height_) != 0 else [0.8 / conversion]\n _horiz_separ_ = _horiz_separ_ if len(_horiz_separ_) != 0 else [3.0 / conversion]\n vert_separ_ = vert_separ_ if len(vert_separ_) != 0 else [0.0]\n operable_ = operable_ if len(operable_) != 0 else [False]\n\n # gather all of the inputs together\n all_inputs = [_subdivide_, _ratio, _win_height_, _sill_height_, _horiz_separ_,\n vert_separ_, operable_]\n\n # ensure matching list lengths across all values\n all_inputs, num_orient = check_matching_inputs(all_inputs)\n\n # get a list of angles used to categorize the faces\n angles = angles_from_num_orient(num_orient)\n\n # loop through the input objects and add apertures\n for obj in hb_objs:\n if isinstance(obj, Model):\n for room in obj.rooms:\n for face in room.faces:\n if can_host_apeture(face):\n orient_i = face_orient_index(face, angles)\n sub, rat, hgt, sil, hor, vert, op = \\\n inputs_by_index(orient_i, all_inputs)\n assign_apertures(face, sub, rat, hgt, sil, hor, vert, op)\n elif isinstance(obj, Room):\n for face in obj.faces:\n if can_host_apeture(face):\n orient_i = face_orient_index(face, angles)\n sub, rat, hgt, sil, hor, vert, op = inputs_by_index(orient_i, all_inputs)\n assign_apertures(face, sub, rat, hgt, sil, hor, vert, op)\n elif isinstance(obj, Face):\n if can_host_apeture(obj):\n orient_i = face_orient_index(obj, angles)\n sub, rat, hgt, sil, hor, vert, op = inputs_by_index(orient_i, all_inputs)\n assign_apertures(obj, sub, rat, hgt, sil, hor, vert, op)\n else:\n raise TypeError(\n 'Input _hb_objs must be a Model Room or Face. Not {}.'.format(type(obj)))",
"category": "Honeybee",
"name": "HB Apertures by Ratio",
"description": "Add apertures to a Honeybee Face or Room given a ratio of aperture area to face area.\n_\nNote that this component will only add Apertures to Faces that are Walls and have\nan Outdoors boundary condition.\n-"
Expand Down
28 changes: 19 additions & 9 deletions honeybee_grasshopper_core/src/HB Apertures by Ratio.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@
the apertures and the area of the parent face. If an array of values
are input here, different ratios will be assigned based on
cardinal direction, starting with north and moving clockwise.
_subdivide_: Boolean to note whether to generate a single window in the
center of each Face (False) or to generate a series of rectangular
_subdivide_: Boolean to note whether to generate only one or two windows
for each Face (False) or to generate a series of repeating rectangular
windows using the other inputs below (True). The latter is often more
realistic and is important to consider for detailed daylight and
thermal comfort simulations but the former is likely better when the
only concern is building energy use since energy use doesn't change
much while the glazing ratio remains constant. (Default: True).
realistic and distributes the windows across the parent Face
for better daylight but the former is likely more useful when
modeling building energy use since energy use doesn't change
signifcantly while the glazing ratio remains constant. (Default: True).
_
Note that this input can also be the integer -1 to completely turn
off all spltting of the base face into underling rectangles. By
default, a False value here will result in two windows generated
for and input pentagonal gabled geometry - one rectangle and one
triangle. This is better for engines like EnergyPlus that cannot
model windows with more than 4 vertices. However, if a single
pentagonal window is desired for such a shape, setting this
input to -1 will produce such a result.
_win_height_: A number for the target height of the output apertures.
Note that, if the ratio is too large for the height, the ratio will
take precedence and the actual aperture height will be larger
Expand Down Expand Up @@ -64,7 +73,7 @@

ghenv.Component.Name = 'HB Apertures by Ratio'
ghenv.Component.NickName = 'AperturesByRatio'
ghenv.Component.Message = '1.8.0'
ghenv.Component.Message = '1.8.1'
ghenv.Component.Category = 'Honeybee'
ghenv.Component.SubCategory = '0 :: Create'
ghenv.Component.AdditionalHelpFromDocStrings = '4'
Expand Down Expand Up @@ -95,10 +104,11 @@ def can_host_apeture(face):

def assign_apertures(face, sub, rat, hgt, sil, hor, vert, op):
"""Assign apertures to a Face based on a set of inputs."""
if sub:
if sub > 0:
face.apertures_by_ratio_rectangle(rat, hgt, sil, hor, vert, tolerance)
else:
face.apertures_by_ratio(rat, tolerance)
rect = True if sub == 0 else False
face.apertures_by_ratio(rat, tolerance, rect)

# try to assign the operable property
if op:
Expand Down
Binary file modified honeybee_grasshopper_core/user_objects/HB Apertures by Ratio.ghuser
Binary file not shown.

0 comments on commit 816691c

Please sign in to comment.