Skip to content

Commit

Permalink
fix(create): Enable Set Story to use longest list logic
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Jan 12, 2024
1 parent fdbfd56 commit 2072cef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions honeybee_grasshopper_core/json/HB_Set_Story.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.7.0",
"version": "1.7.1",
"nickname": "SetStory",
"outputs": [
[
Expand All @@ -21,15 +21,15 @@
"default": null
},
{
"access": "item",
"access": "list",
"name": "_story",
"description": "Text for the story 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\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 room_dup = room.duplicate()\n room_dup.story = _story\n rooms.append(room_dup)\n",
"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 story_id = longest_list(_story, i)\n room_dup = room.duplicate()\n room_dup.story = story_id\n rooms.append(room_dup)\n",
"category": "Honeybee",
"name": "HB Set Story",
"description": "Set text for the story identifier for honeybee Rooms.\n_\nRooms sharing the same story identifier are considered part of the same story\nin a Model.\n-"
Expand Down
9 changes: 5 additions & 4 deletions honeybee_grasshopper_core/src/HB Set Story.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
Args:
_rooms: Honeybee Rooms to which the input _story should be assigned.
_story: Text for the story identifier to which the rooms belong.
Returns:
report: ...
rooms: The input Rooms with their stories set.
"""

ghenv.Component.Name = 'HB Set Story'
ghenv.Component.NickName = 'SetStory'
ghenv.Component.Message = '1.7.0'
ghenv.Component.Message = '1.7.1'
ghenv.Component.Category = 'Honeybee'
ghenv.Component.SubCategory = '0 :: Create'
ghenv.Component.AdditionalHelpFromDocStrings = '0'
Expand All @@ -37,7 +37,7 @@
raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try: # import the ladybug_rhino dependencies
from ladybug_rhino.grasshopper import all_required_inputs
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))

Expand All @@ -47,6 +47,7 @@
for i, room in enumerate(_rooms):
assert isinstance(room, Room), \
'Expected honeybee room. Got {}.'.format(type(room))
story_id = longest_list(_story, i)
room_dup = room.duplicate()
room_dup.story = _story
room_dup.story = story_id
rooms.append(room_dup)
Binary file modified honeybee_grasshopper_core/user_objects/HB Set Story.ghuser
Binary file not shown.

0 comments on commit 2072cef

Please sign in to comment.