Skip to content

Commit

Permalink
fix(modifier): Update components to assign modifiers to Models
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Sep 29, 2023
1 parent fd8e143 commit f4cda2b
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 31 deletions.
Binary file modified honeybee_grasshopper_radiance/icon/HB Apply Face Modifier.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified honeybee_grasshopper_radiance/icon/HB Apply ModifierSet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified honeybee_grasshopper_radiance/icon/HB Apply Shade Modifier.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified honeybee_grasshopper_radiance/icon/HB Apply Window Modifier.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.6.0",
"version": "1.6.1",
"nickname": "ApplyFaceMod",
"outputs": [
[
Expand All @@ -16,7 +16,7 @@
{
"access": "list",
"name": "_hb_objs",
"description": "Honeybee Faces, Doors or Rooms to which the input _mod should\nbe assigned. For the case of a Honeybee Room, the modifier\nwill only be applied to the Room's outdoor walls. Note that, if you\nneed to assign a modifier to all the roofs, floors, etc. of a\nRoom, the best practice is to create a ModifierSet and assing that\nto the Room.",
"description": "Honeybee Faces, Doors, Rooms or a Model to which the input _mod should\nbe assigned. For the case of Rooms or a Model, the modifier\nwill only be applied to the Room's outdoor walls. Note that, if you\nneed to assign a modifier to all the roofs, floors, etc. of a\nRoom, the best practice is to create a ModifierSet and assing that\nto the Room.",
"type": "System.Object",
"default": null
},
Expand All @@ -29,7 +29,7 @@
}
],
"subcategory": "1 :: Modifiers",
"code": "\n\ntry: # import the honeybee-radiance extension\n from honeybee_radiance.lib.modifiers import modifier_by_identifier\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_radiance:\\n\\t{}'.format(e))\n\ntry: # import the core honeybee dependencies\n from honeybee.boundarycondition import Outdoors\n from honeybee.facetype import Wall\n from honeybee.room import Room\n from honeybee.face import Face\n from honeybee.door import Door\n from honeybee.orientation import angles_from_num_orient, face_orient_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}}.{{plugin}} import all_required_inputs\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\ndef is_exterior_wall(face):\n \"\"\"Check whether a given Face is an exterior Wall.\"\"\"\n return isinstance(face.boundary_condition, Outdoors) and \\\n isinstance(face.type, Wall)\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 # process the input modifiers\n for i, constr in enumerate(_mod):\n if isinstance(constr, str):\n _mod[i] = modifier_by_identifier(constr)\n\n # error message for unrecognized object\n error_msg = 'Input _hb_objs must be a Room, Face, or Door. Not {}.'\n\n # assign the modifiers\n if len(_mod) == 1: # assign indiscriminately, even if it's horizontal\n for obj in hb_objs:\n if isinstance(obj, (Face, Door)):\n obj.properties.radiance.modifier = _mod[0]\n elif isinstance(obj, Room):\n for face in obj.faces:\n if is_exterior_wall(face):\n face.properties.radiance.modifier = _mod[0]\n else:\n raise TypeError(error_msg.format(type(obj)))\n else: # assign modifiers based on cardinal direction\n angles = angles_from_num_orient(len(_mod))\n for obj in hb_objs:\n if isinstance(obj, (Face, Door)):\n orient_i = face_orient_index(obj, angles)\n if orient_i is not None:\n obj.properties.radiance.modifier = _mod[orient_i]\n elif isinstance(obj, Room):\n for face in obj.faces:\n if is_exterior_wall(face):\n orient_i = face_orient_index(face, angles)\n if orient_i is not None:\n face.properties.radiance.modifier = _mod[orient_i]\n else:\n raise TypeError(error_msg.format(type(obj)))\n",
"code": "\n\ntry: # import the honeybee-radiance extension\n from honeybee_radiance.lib.modifiers import modifier_by_identifier\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_radiance:\\n\\t{}'.format(e))\n\ntry: # import the core honeybee dependencies\n from honeybee.boundarycondition import Outdoors\n from honeybee.facetype import Wall\n from honeybee.model import Model\n from honeybee.room import Room\n from honeybee.face import Face\n from honeybee.door import Door\n from honeybee.orientation import angles_from_num_orient, face_orient_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}}.{{plugin}} import all_required_inputs\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\ndef is_exterior_wall(face):\n \"\"\"Check whether a given Face is an exterior Wall.\"\"\"\n return isinstance(face.boundary_condition, Outdoors) and \\\n isinstance(face.type, Wall)\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 # process the input modifiers\n for i, constr in enumerate(_mod):\n if isinstance(constr, str):\n _mod[i] = modifier_by_identifier(constr)\n\n # error message for unrecognized object\n error_msg = 'Input _hb_objs must be a Room, Face, or Door. Not {}.'\n\n # assign the modifiers\n if len(_mod) == 1: # assign indiscriminately, even if it's horizontal\n for obj in hb_objs:\n if isinstance(obj, (Face, Door)):\n obj.properties.radiance.modifier = _mod[0]\n elif isinstance(obj, (Room, Model)):\n for face in obj.faces:\n if is_exterior_wall(face):\n face.properties.radiance.modifier = _mod[0]\n else:\n raise TypeError(error_msg.format(type(obj)))\n else: # assign modifiers based on cardinal direction\n angles = angles_from_num_orient(len(_mod))\n for obj in hb_objs:\n if isinstance(obj, (Face, Door)):\n orient_i = face_orient_index(obj, angles)\n if orient_i is not None:\n obj.properties.radiance.modifier = _mod[orient_i]\n elif isinstance(obj, (Room, Model)):\n for face in obj.faces:\n if is_exterior_wall(face):\n orient_i = face_orient_index(face, angles)\n if orient_i is not None:\n face.properties.radiance.modifier = _mod[orient_i]\n else:\n raise TypeError(error_msg.format(type(obj)))\n",
"category": "HB-Radiance",
"name": "HB Apply Face Modifier",
"description": "Apply a Modifier to Honeybee Faces, Doors or Room walls.\n_\nThis component supports the assigning of different modifiers based on cardinal\norientation, provided that a list of Modifiers are input to the _mod. \n-"
Expand Down
6 changes: 3 additions & 3 deletions honeybee_grasshopper_radiance/json/HB_Apply_ModifierSet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.6.0",
"version": "1.6.1",
"nickname": "ApplyModSet",
"outputs": [
[
Expand All @@ -16,7 +16,7 @@
{
"access": "list",
"name": "_rooms",
"description": "Honeybee Rooms to which the input _mod_set should be assigned.",
"description": "Honeybee Rooms to which the input _mod_set should be assigned.\nThis can also be a Honeybee Model for which all Rooms\nwill be assigned the ModifierSet.",
"type": "System.Object",
"default": null
},
Expand All @@ -29,7 +29,7 @@
}
],
"subcategory": "1 :: Modifiers",
"code": "\n\ntry: # import the honeybee-radiance extension\n from honeybee_radiance.lib.modifiersets import modifier_set_by_identifier\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_radiance:\\n\\t{}'.format(e))\n\ntry: # import the ladybug_{{cad}} dependencies\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\nif all_required_inputs(ghenv.Component):\n # duplicate the initial objects\n rooms = [obj.duplicate() for obj in _rooms]\n\n # process the input modifier set if it's a string\n if isinstance(_mod_set, str):\n _mod_set = modifier_set_by_identifier(_mod_set)\n\n # assign the modifier set\n for rm in rooms:\n rm.properties.radiance.modifier_set = _mod_set\n",
"code": "\ntry: # import the honeybee extension\n from honeybee.model import Model\n from honeybee.room import Room\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the honeybee-radiance extension\n from honeybee_radiance.lib.modifiersets import modifier_set_by_identifier\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_radiance:\\n\\t{}'.format(e))\n\ntry: # import the ladybug_{{cad}} dependencies\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\nif all_required_inputs(ghenv.Component):\n # duplicate the initial objects\n rooms = [obj.duplicate() for obj in _rooms]\n\n # extract any rooms from the input Models\n hb_objs = []\n for hb_obj in rooms:\n if isinstance(hb_obj, Model):\n hb_objs.extend(hb_obj.rooms)\n elif isinstance(hb_obj, Room):\n hb_objs.append(hb_obj)\n else:\n raise ValueError(\n 'Expected Honeybee Room or Model. Got {}.'.format(type(hb_obj)))\n\n # process the input modifier set if it's a string\n if isinstance(_mod_set, str):\n _mod_set = modifier_set_by_identifier(_mod_set)\n\n # assign the modifier set\n for rm in hb_objs:\n rm.properties.radiance.modifier_set = _mod_set\n",
"category": "HB-Radiance",
"name": "HB Apply ModifierSet",
"description": "Apply ModifierSet to Honeybee Rooms.\n-"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.6.0",
"version": "1.6.1",
"nickname": "ApplyShadeMod",
"outputs": [
[
Expand All @@ -16,7 +16,7 @@
{
"access": "list",
"name": "_hb_objs",
"description": "Honeybee Shades, Apertures, Doors, Faces, or Rooms to which the\ninput _mod should be assigned. For the case of a Honeybee Aperture,\nDoor, Face or Room, the Modifier will be assigned to only the\nchild shades directly assigned to that object. So passing in a Room\nwill not change the modifier of shades assigned to Apertures\nof the Room's Faces. If this is the desired outcome, then the Room\nshould be deconstructed into its child objects before using\nthis component.",
"description": "Honeybee Shades, Apertures, Doors, Faces, Rooms, or a Model to which the\ninput _mod should be assigned. For the case of a Honeybee Aperture,\nDoor, Face, Room or Model, the Modifier will be assigned to only the\nchild shades directly assigned to that object. So passing in a Room\nwill not change the modifier of shades assigned to Apertures\nof the Room's Faces. If this is the desired outcome, then the Room\nshould be deconstructed into its child objects before using\nthis component.",
"type": "System.Object",
"default": null
},
Expand All @@ -29,7 +29,7 @@
}
],
"subcategory": "1 :: Modifiers",
"code": "\n\ntry: # import the honeybee-radiance extension\n from honeybee_radiance.lib.modifiers import modifier_by_identifier\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_radiance:\\n\\t{}'.format(e))\n\ntry: # import the core honeybee dependencies\n from honeybee.shade import Shade\n from honeybee.room import Room\n from honeybee.face import Face\n from honeybee.aperture import Aperture\n from honeybee.door import Door\n from honeybee.orientation import angles_from_num_orient, face_orient_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}}.{{plugin}} import all_required_inputs\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\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 # process the input modifiers\n for i, mod in enumerate(_mod):\n if isinstance(mod, str):\n _mod[i] = modifier_by_identifier(mod)\n\n # error message for unrecognized object\n error_msg = 'Input _hb_objs must be a Room, Face, Aperture, Door, or Shade. Not {}.'\n\n # assign the modifiers\n if len(_mod) == 1:\n for obj in hb_objs:\n if isinstance(obj, Shade):\n obj.properties.radiance.modifier = _mod[0]\n elif isinstance(obj, (Aperture, Face, Room, Door)):\n for shd in obj.shades:\n shd.properties.radiance.modifier = _mod[0]\n else:\n raise TypeError(error_msg.format(type(obj)))\n else: # assign modifiers based on cardinal direction\n angles = angles_from_num_orient(len(_mod))\n for obj in hb_objs:\n if isinstance(obj, (Aperture, Face, Door)):\n orient_i = face_orient_index(obj, angles)\n if orient_i is not None:\n for shd in obj.shades:\n shd.properties.radiance.modifier = _mod[orient_i]\n elif isinstance(obj, Shade):\n obj.properties.radiance.modifier = _mod[0]\n elif isinstance(obj, Room):\n for shd in obj.shades:\n shd.properties.radiance.modifier = _mod[0]\n else:\n raise TypeError(error_msg.format(type(obj)))\n\n",
"code": "\n\ntry: # import the honeybee-radiance extension\n from honeybee_radiance.lib.modifiers import modifier_by_identifier\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_radiance:\\n\\t{}'.format(e))\n\ntry: # import the core honeybee dependencies\n from honeybee.shade import Shade\n from honeybee.model import Model\n from honeybee.room import Room\n from honeybee.face import Face\n from honeybee.aperture import Aperture\n from honeybee.door import Door\n from honeybee.orientation import angles_from_num_orient, face_orient_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}}.{{plugin}} import all_required_inputs\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\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 # process the input modifiers\n for i, mod in enumerate(_mod):\n if isinstance(mod, str):\n _mod[i] = modifier_by_identifier(mod)\n\n # error message for unrecognized object\n error_msg = 'Input _hb_objs must be a Room, Face, Aperture, Door, or Shade. Not {}.'\n\n # assign the modifiers\n if len(_mod) == 1:\n for obj in hb_objs:\n if isinstance(obj, Shade):\n obj.properties.radiance.modifier = _mod[0]\n elif isinstance(obj, (Aperture, Face, Room, Door)):\n for shd in obj.shades:\n shd.properties.radiance.modifier = _mod[0]\n elif isinstance(obj, Model):\n for shd in obj.orphaned_shades:\n shd.properties.radiance.modifier = _mod[0]\n else:\n raise TypeError(error_msg.format(type(obj)))\n else: # assign modifiers based on cardinal direction\n angles = angles_from_num_orient(len(_mod))\n for obj in hb_objs:\n if isinstance(obj, (Aperture, Face, Door)):\n orient_i = face_orient_index(obj, angles)\n if orient_i is not None:\n for shd in obj.shades:\n shd.properties.radiance.modifier = _mod[orient_i]\n elif isinstance(obj, Shade):\n obj.properties.radiance.modifier = _mod[0]\n elif isinstance(obj, Room):\n for shd in obj.shades:\n shd.properties.radiance.modifier = _mod[0]\n elif isinstance(obj, Model):\n for shd in obj.orphaned_shades:\n shd.properties.radiance.modifier = _mod[0]\n else:\n raise TypeError(error_msg.format(type(obj)))\n\n",
"category": "HB-Radiance",
"name": "HB Apply Shade Modifier",
"description": "Apply a Modifier to Honeybee Shade objects. Alternatively, it can assign a Modifier\nto all of the child shades of an Aperture, Door, Face, or a Room.\n_\nThis component supports the assigning of different modifiers based on cardinal\norientation, provided that a list of Modifiers are input to the _mod. \n-"
Expand Down
Loading

0 comments on commit f4cda2b

Please sign in to comment.