Skip to content

Commit

Permalink
fix(organize): Ensure that room model shades are output
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Nov 8, 2024
1 parent 08490bd commit dade9a0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
Binary file modified honeybee_grasshopper_core/icon/HB Faces by Type.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions honeybee_grasshopper_core/json/HB_Faces_by_Type.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.0",
"version": "1.8.1",
"nickname": "FacesByType",
"outputs": [
[
Expand Down Expand Up @@ -106,7 +106,7 @@
}
],
"subcategory": "2 :: Organize",
"code": "\ntry: # import the core honeybee dependencies\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.shade import Shade\n from honeybee.shademesh import ShadeMesh\n from honeybee.boundarycondition import Surface\n from honeybee.facetype import Wall, RoofCeiling, Floor, AirBoundary\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\ntry: # import the honeybee-energy extension\n from honeybee.boundarycondition import Adiabatic\nexcept ImportError: # honeybee-energy not installed\n Adiabatic = None # don't worry about Aidabatic; Surface is the only interior bc\n\n\ndef add_shade(hb_obj):\n \"\"\"Add an object's shades to the relevant lists.\"\"\"\n outdoor_shades.extend([shd for shd in hb_obj.outdoor_shades])\n indoor_shades.extend([shd for shd in hb_obj.indoor_shades])\n\ndef add_door(dr):\n \"\"\"Add a door to the relevant lists.\"\"\"\n bc = dr.boundary_condition\n add_shade(dr)\n if isinstance(bc, Surface):\n interior_doors.append(dr)\n else:\n doors.append(dr)\n\ndef add_aperture(ap):\n \"\"\"Add an aperture to the relevant lists.\"\"\"\n bc = ap.boundary_condition\n add_shade(ap)\n if isinstance(bc, Surface):\n interior_apertures.append(ap)\n else:\n apertures.append(ap)\n\ndef add_face(face):\n \"\"\"Add a face to the relevant lists.\"\"\"\n add_shade(face)\n bc = face.boundary_condition\n type = face.type\n if isinstance(type, Wall):\n if isinstance(bc, (Surface, Adiabatic)):\n interior_walls.append(face)\n else:\n walls.append(face)\n elif isinstance(type, RoofCeiling):\n if isinstance(bc, (Surface, Adiabatic)):\n ceilings.append(face)\n else:\n roofs.append(face)\n elif isinstance(type, Floor):\n if isinstance(bc, (Surface, Adiabatic)):\n interior_floors.append(face)\n else:\n exterior_floors.append(face)\n elif isinstance(type, AirBoundary):\n air_walls.append(face)\n\n # add the apertures, doors, and shades\n for ap in face.apertures:\n add_aperture(ap)\n for dr in face.doors:\n add_door(dr)\n\n\nif all_required_inputs(ghenv.Component):\n # lists of {{cad}} geometry to be filled with content\n walls = []\n interior_walls = []\n roofs = []\n ceilings = []\n exterior_floors = []\n interior_floors = []\n air_walls = []\n apertures = []\n interior_apertures = []\n doors = []\n interior_doors = []\n outdoor_shades = []\n indoor_shades = []\n shade_meshes = []\n\n # loop through all objects and add them\n for obj in _hb_objs:\n if isinstance(obj, Model):\n for room in obj.rooms:\n for face in room.faces:\n add_face(face)\n for face in obj.orphaned_faces:\n add_face(face)\n for ap in obj.orphaned_apertures:\n add_aperture(ap)\n for dr in obj.orphaned_doors:\n add_door(dr)\n outdoor_shades.extend(obj.orphaned_shades)\n outdoor_shades.extend(obj.shade_meshes)\n elif isinstance(obj, Room):\n add_shade(obj)\n for face in obj:\n add_face(face)\n elif isinstance(obj, Face):\n add_face(obj)\n elif isinstance(obj, Aperture):\n add_aperture(obj)\n elif isinstance(obj, Door):\n add_door(obj)\n elif isinstance(obj, Shade):\n outdoor_shades.append(obj)\n elif isinstance(obj, ShadeMesh):\n outdoor_shades.append(obj)",
"code": "\ntry: # import the core honeybee dependencies\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.shade import Shade\n from honeybee.shademesh import ShadeMesh\n from honeybee.boundarycondition import Surface\n from honeybee.facetype import Wall, RoofCeiling, Floor, AirBoundary\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\ntry: # import the honeybee-energy extension\n from honeybee.boundarycondition import Adiabatic\nexcept ImportError: # honeybee-energy not installed\n Adiabatic = None # don't worry about Aidabatic; Surface is the only interior bc\n\n\ndef add_shade(hb_obj):\n \"\"\"Add an object's shades to the relevant lists.\"\"\"\n outdoor_shades.extend([shd for shd in hb_obj.outdoor_shades])\n indoor_shades.extend([shd for shd in hb_obj.indoor_shades])\n\ndef add_door(dr):\n \"\"\"Add a door to the relevant lists.\"\"\"\n bc = dr.boundary_condition\n add_shade(dr)\n if isinstance(bc, Surface):\n interior_doors.append(dr)\n else:\n doors.append(dr)\n\ndef add_aperture(ap):\n \"\"\"Add an aperture to the relevant lists.\"\"\"\n bc = ap.boundary_condition\n add_shade(ap)\n if isinstance(bc, Surface):\n interior_apertures.append(ap)\n else:\n apertures.append(ap)\n\ndef add_face(face):\n \"\"\"Add a face to the relevant lists.\"\"\"\n add_shade(face)\n bc = face.boundary_condition\n type = face.type\n if isinstance(type, Wall):\n if isinstance(bc, (Surface, Adiabatic)):\n interior_walls.append(face)\n else:\n walls.append(face)\n elif isinstance(type, RoofCeiling):\n if isinstance(bc, (Surface, Adiabatic)):\n ceilings.append(face)\n else:\n roofs.append(face)\n elif isinstance(type, Floor):\n if isinstance(bc, (Surface, Adiabatic)):\n interior_floors.append(face)\n else:\n exterior_floors.append(face)\n elif isinstance(type, AirBoundary):\n air_walls.append(face)\n\n # add the apertures, doors, and shades\n for ap in face.apertures:\n add_aperture(ap)\n for dr in face.doors:\n add_door(dr)\n\n\nif all_required_inputs(ghenv.Component):\n # lists of {{cad}} geometry to be filled with content\n walls = []\n interior_walls = []\n roofs = []\n ceilings = []\n exterior_floors = []\n interior_floors = []\n air_walls = []\n apertures = []\n interior_apertures = []\n doors = []\n interior_doors = []\n outdoor_shades = []\n indoor_shades = []\n shade_meshes = []\n\n # loop through all objects and add them\n for obj in _hb_objs:\n if isinstance(obj, Model):\n for room in obj.rooms:\n add_shade(room)\n for face in room.faces:\n add_face(face)\n for face in obj.orphaned_faces:\n add_face(face)\n for ap in obj.orphaned_apertures:\n add_aperture(ap)\n for dr in obj.orphaned_doors:\n add_door(dr)\n outdoor_shades.extend(obj.orphaned_shades)\n outdoor_shades.extend(obj.shade_meshes)\n elif isinstance(obj, Room):\n add_shade(obj)\n for face in obj:\n add_face(face)\n elif isinstance(obj, Face):\n add_face(obj)\n elif isinstance(obj, Aperture):\n add_aperture(obj)\n elif isinstance(obj, Door):\n add_door(obj)\n elif isinstance(obj, Shade):\n if obj.is_indoor:\n indoor_shades.append(obj)\n else:\n outdoor_shades.append(obj)\n elif isinstance(obj, ShadeMesh):\n outdoor_shades.append(obj)",
"category": "Honeybee",
"name": "HB Faces by Type",
"description": "Separate the faces/sub-faces of honeybee Rooms, Faces, Apertures, Doors, or Shades\nby object and face type.\n-"
Expand Down
8 changes: 6 additions & 2 deletions honeybee_grasshopper_core/src/HB Faces by Type.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

ghenv.Component.Name = 'HB Faces by Type'
ghenv.Component.NickName = 'FacesByType'
ghenv.Component.Message = '1.8.0'
ghenv.Component.Message = '1.8.1'
ghenv.Component.Category = 'Honeybee'
ghenv.Component.SubCategory = '2 :: Organize'
ghenv.Component.AdditionalHelpFromDocStrings = '3'
Expand Down Expand Up @@ -139,6 +139,7 @@ def add_face(face):
for obj in _hb_objs:
if isinstance(obj, Model):
for room in obj.rooms:
add_shade(room)
for face in room.faces:
add_face(face)
for face in obj.orphaned_faces:
Expand All @@ -160,6 +161,9 @@ def add_face(face):
elif isinstance(obj, Door):
add_door(obj)
elif isinstance(obj, Shade):
outdoor_shades.append(obj)
if obj.is_indoor:
indoor_shades.append(obj)
else:
outdoor_shades.append(obj)
elif isinstance(obj, ShadeMesh):
outdoor_shades.append(obj)
Binary file modified honeybee_grasshopper_core/user_objects/HB Faces by Type.ghuser
Binary file not shown.
Binary file modified samples/model_creation_workflows.gh
Binary file not shown.

0 comments on commit dade9a0

Please # to comment.