Skip to content

Commit

Permalink
feat(create): Add a component for setting Room zones
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Jan 6, 2025
1 parent 901fe35 commit f12340c
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
Binary file added honeybee_grasshopper_core/icon/HB Set Zone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions honeybee_grasshopper_core/json/HB_Set_Zone.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "1.8.0",
"nickname": "SetZone",
"outputs": [
[
{
"access": "None",
"name": "rooms",
"description": "The input Rooms with their zones set.",
"type": null,
"default": null
}
]
],
"inputs": [
{
"access": "list",
"name": "_rooms",
"description": "Honeybee Rooms to which the input _zone identifier should be assigned.",
"type": "System.Object",
"default": null
},
{
"access": "list",
"name": "_zone",
"description": "Text for the zone identifier to which the rooms belong.",
"type": "string",
"default": null
}
],
"subcategory": "0 :: Create",
"code": "\n\ntry: # import the honeybee-energy extension\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 ladybug_{{cad}} dependencies\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, longest_list\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 rooms = []\n for i, room in enumerate(_rooms):\n assert isinstance(room, Room), \\\n 'Expected honeybee room. Got {}.'.format(type(room))\n zone_id = longest_list(_zone, i)\n room_dup = room.duplicate()\n room_dup.zone = zone_id\n rooms.append(room_dup)\n",
"category": "Honeybee",
"name": "HB Set Zone",
"description": "Set text for the zone identifier for honeybee Rooms.\n_\nRooms sharing the same zone identifier are considered part of the same zone\nin a Model. If a zone identifier has not been specified for a given Room, it\nwill be the same as the Room identifier.\n-"
}
54 changes: 54 additions & 0 deletions honeybee_grasshopper_core/src/HB Set Zone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Honeybee: A Plugin for Environmental Analysis (GPL)
# This file is part of Honeybee.
#
# Copyright (c) 2024, Ladybug Tools.
# You should have received a copy of the GNU Affero General Public License
# along with Honeybee; If not, see <http://www.gnu.org/licenses/>.
#
# @license AGPL-3.0-or-later <https://spdx.org/licenses/AGPL-3.0-or-later>

"""
Set text for the zone identifier for honeybee Rooms.
_
Rooms sharing the same zone identifier are considered part of the same zone
in a Model. If a zone identifier has not been specified for a given Room, it
will be the same as the Room identifier.
-
Args:
_rooms: Honeybee Rooms to which the input _zone identifier should be assigned.
_zone: Text for the zone identifier to which the rooms belong.
Returns:
report: ...
rooms: The input Rooms with their zones set.
"""

ghenv.Component.Name = 'HB Set Zone'
ghenv.Component.NickName = 'SetZone'
ghenv.Component.Message = '1.8.0'
ghenv.Component.Category = 'Honeybee'
ghenv.Component.SubCategory = '0 :: Create'
ghenv.Component.AdditionalHelpFromDocStrings = '0'


try: # import the honeybee-energy extension
from honeybee.room import Room
except ImportError as e:
raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try: # import the ladybug_rhino dependencies
from ladybug_rhino.grasshopper import all_required_inputs, longest_list
except ImportError as e:
raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component):
rooms = []
for i, room in enumerate(_rooms):
assert isinstance(room, Room), \
'Expected honeybee room. Got {}.'.format(type(room))
zone_id = longest_list(_zone, i)
room_dup = room.duplicate()
room_dup.zone = zone_id
rooms.append(room_dup)
Binary file not shown.

0 comments on commit f12340c

Please sign in to comment.