Skip to content

Commit

Permalink
feat(door): Allow Shades to be assigned to Doors
Browse files Browse the repository at this point in the history
This commit brings the library in line with [this PR on honeybee-core](ladybug-tools/honeybee-core#52).
  • Loading branch information
chriswmackey authored and Chris Mackey committed Jan 27, 2020
1 parent cd583ea commit f145575
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 18 deletions.
6 changes: 3 additions & 3 deletions honeybee_grasshopper_core/src/HB Add Shade.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>

"""
Add a Honeybee Shades to an Aperture, Face or Room.
Add a Honeybee Shades to an Aperture, Door, Face or Room.
-
Args:
_hb_obj: A Honeybee Aperture, Face or a Room to which the shades should
_hb_obj: A Honeybee Aperture, Door, Face or a Room to which the shades should
be added.
out_shades_: A list of Honeybee Shade objects to be added to the outside
of the input _hb_objs.
Expand All @@ -29,7 +29,7 @@

ghenv.Component.Name = "HB Add Shade"
ghenv.Component.NickName = 'AddShade'
ghenv.Component.Message = '0.1.0'
ghenv.Component.Message = '0.2.0'
ghenv.Component.Category = "HoneybeeCore"
ghenv.Component.SubCategory = '0 :: Create'
ghenv.Component.AdditionalHelpFromDocStrings = "5"
Expand Down
14 changes: 10 additions & 4 deletions honeybee_grasshopper_core/src/HB Deconstruct Object.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

ghenv.Component.Name = "HB Deconstruct Object"
ghenv.Component.NickName = 'DecnstrObj'
ghenv.Component.Message = '0.1.0'
ghenv.Component.Message = '0.2.0'
ghenv.Component.Category = "HoneybeeCore"
ghenv.Component.SubCategory = '0 :: Create'
ghenv.Component.AdditionalHelpFromDocStrings = "1"
Expand All @@ -57,6 +57,12 @@
except ImportError as e:
raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

def deconstruct_door(door, doors, shades):
"""Deconstruct Door object."""
doors.append(door)
for shd in door.shades:
shades.append(shd)

def deconstruct_aperture(aperture, apertures, shades):
"""Deconstruct Aperture object."""
apertures.append(aperture)
Expand All @@ -69,7 +75,7 @@ def deconstruct_face(face, faces, apertures, doors, shades):
for ap in face.apertures:
deconstruct_aperture(ap, apertures, shades)
for dr in face.doors:
doors.append(dr)
deconstruct_door(dr, doors, shades)
for shd in face.shades:
shades.append(shd)

Expand All @@ -95,10 +101,10 @@ def deconstruct_room(room, faces, apertures, doors, shades):
deconstruct_face(_hb_obj, faces, apertures, doors, shades)
elif isinstance(_hb_obj, Aperture):
deconstruct_aperture(_hb_obj, apertures, shades)
elif isinstance(_hb_obj, Door):
deconstruct_door(_hb_obj, doors, shades)
elif isinstance(_hb_obj, Shade):
shades.append(_hb_obj)
elif isinstance(_hb_obj, Door):
doors.append(_hb_obj)
else:
raise TypeError(
'Unrecognized honeybee object type: {}'.format(type(_hb_obj)))
3 changes: 2 additions & 1 deletion honeybee_grasshopper_core/src/HB Visualize by Type.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

ghenv.Component.Name = "HB Visualize by Type"
ghenv.Component.NickName = 'VizByType'
ghenv.Component.Message = '0.1.0'
ghenv.Component.Message = '0.2.0'
ghenv.Component.Category = "HoneybeeCore"
ghenv.Component.SubCategory = '1 :: Visualize'
ghenv.Component.AdditionalHelpFromDocStrings = "2"
Expand Down Expand Up @@ -124,6 +124,7 @@ def add_shade(hb_obj):
else:
apertures.append(from_face3d(ap.geometry))
for dr in face.doors:
add_shade(dr)
if isinstance(bc, Surface):
interior_doors.append(from_face3d(dr.geometry))
else:
Expand Down
14 changes: 8 additions & 6 deletions honeybee_grasshopper_core/src/HB Vizualize All.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

ghenv.Component.Name = "HB Vizualize All"
ghenv.Component.NickName = 'VizAll'
ghenv.Component.Message = '0.1.1'
ghenv.Component.Message = '0.2.0'
ghenv.Component.Category = "HoneybeeCore"
ghenv.Component.SubCategory = '1 :: Visualize'
ghenv.Component.AdditionalHelpFromDocStrings = "1"
Expand Down Expand Up @@ -52,9 +52,11 @@ def add_shade(shd, shades):
"""Add Shade geometry to a shades list."""
shades.append(from_face3d(shd.geometry))

def add_door(door, geo):
"""Add Door geometry to a geo list."""
def add_door(door, geo, shades):
"""Add Door geometry to a geo list and shades list."""
geo.append(from_face3d(door.geometry))
for shd in door.shades:
add_shade(shd, shades)

def add_aperture(aperture, geo, shades):
"""Add Aperture geometry to a geo and shades list."""
Expand All @@ -68,7 +70,7 @@ def add_face(face, geo, shades):
for ap in face.apertures:
add_aperture(ap, geo, shades)
for dr in face.doors:
add_door(dr, geo)
add_door(dr, geo, shades)
for shd in face.shades:
add_shade(shd, shades)

Expand All @@ -90,7 +92,7 @@ def add_model(model, geo, shades):
for ap in model.orphaned_apertures:
add_aperture(ap, geo, shades)
for dr in model.orphaned_doors:
add_door(dr, geo)
add_door(dr, geo, shades)
for shd in model.orphaned_shades:
add_shade(shd, shades)

Expand All @@ -111,7 +113,7 @@ def add_model(model, geo, shades):
elif isinstance(hb_obj, Shade):
add_shade(hb_obj, shades)
elif isinstance(hb_obj, Door):
add_door(hb_obj, geo)
add_door(hb_obj, geo, shades)
elif isinstance(hb_obj, Model):
add_model(hb_obj, geo, shades)
else:
Expand Down
14 changes: 10 additions & 4 deletions honeybee_grasshopper_core/src/HB Vizualize Wireframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

ghenv.Component.Name = "HB Vizualize Wireframe"
ghenv.Component.NickName = 'VizWireF'
ghenv.Component.Message = '0.1.1'
ghenv.Component.Message = '0.2.0'
ghenv.Component.Category = "HoneybeeCore"
ghenv.Component.SubCategory = '1 :: Visualize'
ghenv.Component.AdditionalHelpFromDocStrings = "1"
Expand All @@ -45,6 +45,12 @@
raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


def add_door(door, geo):
"""Add Door geometry to a geo list."""
geo.append(from_face3d_to_wireframe(door.geometry))
for shd in door.shades:
geo.append(from_face3d_to_wireframe(shd.geometry))

def add_aperture(aperture, geo):
"""Add Aperture geometry to a geo list."""
geo.append(from_face3d_to_wireframe(aperture.geometry))
Expand All @@ -57,7 +63,7 @@ def add_face(face, geo):
for ap in face.apertures:
add_aperture(ap, geo)
for dr in face.doors:
geo.append(from_face3d_to_wireframe(dr.geometry))
add_door(ap, geo)
for shd in face.shades:
geo.append(from_face3d_to_wireframe(shd.geometry))

Expand Down Expand Up @@ -94,9 +100,9 @@ def add_model(model, geo):
add_face(hb_obj, geo)
elif isinstance(hb_obj, Aperture):
add_aperture(hb_obj, geo)
elif isinstance(hb_obj, Shade):
geo.append(from_face3d_to_wireframe(hb_obj.geometry))
elif isinstance(hb_obj, Door):
add_door(hb_obj, geo)
elif isinstance(hb_obj, Shade):
geo.append(from_face3d_to_wireframe(hb_obj.geometry))
elif isinstance(hb_obj, Model):
add_model(hb_obj, geo)
Expand Down
Binary file modified honeybee_grasshopper_core/user_objects/HB Add Shade.ghuser
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified honeybee_grasshopper_core/user_objects/HB Vizualize All.ghuser
Binary file not shown.
Binary file not shown.
Binary file modified samples/model_creation_workflows.gh
Binary file not shown.

0 comments on commit f145575

Please sign in to comment.