-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(organize): Expose the ability to filter rooms/faces by attribute
- Loading branch information
1 parent
4ba7ccc
commit c5143ba
Showing
8 changed files
with
123 additions
and
76 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 34 additions & 27 deletions
61
honeybee_grasshopper_core/json/HB_Faces_by_Attribute.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,50 @@ | ||
{ | ||
"version": "1.8.0", | ||
"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.colorobj import ColorFace\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the ladybug_{{cad}} dependencies\n \n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, list_to_data_tree\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 # extract any faces from input Rooms or Models\n faces = []\n for hb_obj in _hb_objs:\n if isinstance(hb_obj, Room):\n faces.extend(hb_obj.faces)\n faces.extend(hb_obj.shades)\n elif isinstance(hb_obj, Room):\n faces.append(hb_obj)\n elif isinstance(hb_obj, Model):\n for room in hb_obj.rooms:\n faces.extend(room.faces)\n faces.extend(room.shades)\n faces.extend(hb_obj.orphaned_faces)\n faces.extend(hb_obj.orphaned_apertures)\n faces.extend(hb_obj.orphaned_doors)\n faces.extend(hb_obj.orphaned_shades)\n faces.extend(hb_obj.shade_meshes)\n else:\n msg = 'Expected Face, Room or Model. Got {}.'.format(type(hb_obj))\n raise TypeError(msg)\n\n # use the ColorFace object to get a set of attributes assigned to the faces\n color_obj = ColorFace(faces, _attribute)\n\n # loop through each of the hb_objs and get the attribute\n if len(value_) == 0:\n values = color_obj.attributes_unique\n hb_objs = [[] for val in values]\n for atr, face in zip(color_obj.attributes, color_obj.flat_faces):\n atr_i = values.index(atr)\n hb_objs[atr_i].append(face)\n else:\n values = [atr for atr in color_obj.attributes_unique if atr in value_]\n hb_objs = [[] for val in values]\n for atr, face in zip(color_obj.attributes, color_obj.flat_faces):\n if atr in values:\n atr_i = values.index(atr)\n hb_objs[atr_i].append(face)\n hb_objs = list_to_data_tree(hb_objs)\n", | ||
"category": "Honeybee", | ||
"inputs": [ | ||
{ | ||
"type": "System.Object", | ||
"name": "_hb_objs", | ||
"access": "list", | ||
"default": null, | ||
"description": "An array of honeybee Rooms, Faces, Apertures, Doors or Shades\nto be separated by their attributes in the Rhino scene." | ||
}, | ||
{ | ||
"type": "string", | ||
"name": "_attribute", | ||
"access": "item", | ||
"default": null, | ||
"description": "Text for the name of the Face attribute with which the\nFaces should be labeled. The Honeybee \"Face Attributes\" component\nlists all of the core attributes of the room. Also, each Honeybee\nextension (ie. Radiance, Energy) includes its own component that\nlists the Face attributes of that extension." | ||
}, | ||
{ | ||
"type": "System.Object", | ||
"name": "value_", | ||
"access": "list", | ||
"default": null, | ||
"description": "An optional value of the attribute that can be used to filter\nthe output rooms. For example, if the input attribute is \"Azimuth\"\na value for the orientation of the Face can be plugged in here\n(eg. \"180\" for south-facing) in order to get Faces with only\nthis oreintation." | ||
} | ||
], | ||
"nickname": "FacesByAttr", | ||
"version": "1.8.1", | ||
"outputs": [ | ||
[ | ||
{ | ||
"access": "None", | ||
"name": "values", | ||
"description": "A list of values with one attribute value for each branch of the\noutput hb_objs.", | ||
"type": null, | ||
"default": null | ||
"name": "values", | ||
"access": "None", | ||
"default": null, | ||
"description": "A list of values with one attribute value for each branch of the\noutput hb_objs." | ||
}, | ||
{ | ||
"access": "None", | ||
"name": "hb_objs", | ||
"description": "A data tree of honeybee faces and sub-faces with each branc\nof the tree representing a different attribute value.", | ||
"type": null, | ||
"default": null | ||
"name": "hb_objs", | ||
"access": "None", | ||
"default": null, | ||
"description": "A data tree of honeybee faces and sub-faces with each branc\nof the tree representing a different attribute value." | ||
} | ||
] | ||
], | ||
"inputs": [ | ||
{ | ||
"access": "list", | ||
"name": "_hb_objs", | ||
"description": "An array of honeybee Rooms, Faces, Apertures, Doors or Shades\nto be separated by their attributes in the Rhino scene.", | ||
"type": "System.Object", | ||
"default": null | ||
}, | ||
{ | ||
"access": "item", | ||
"name": "_attribute", | ||
"description": "Text for the name of the Face attribute with which the\nFaces should be labeled. The Honeybee \"Face Attributes\" component\nlists all of the core attributes of the room. Also, each Honeybee\nextension (ie. Radiance, Energy) includes its own component that\nlists the Face attributes of that extension.", | ||
"type": "string", | ||
"default": null | ||
} | ||
], | ||
"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.colorobj import ColorFace\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the ladybug_{{cad}} dependencies\n \n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, list_to_data_tree\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 # extract any faces from input Rooms or Models\n faces = []\n for hb_obj in _hb_objs:\n if isinstance(hb_obj, Model):\n for room in hb_obj.rooms:\n faces.extend(room.faces)\n faces.extend(room.shades)\n faces.extend(hb_obj.orphaned_faces)\n faces.extend(hb_obj.orphaned_apertures)\n faces.extend(hb_obj.orphaned_doors)\n faces.extend(hb_obj.orphaned_shades)\n faces.extend(hb_obj.shade_meshes)\n elif isinstance(hb_obj, Room):\n faces.extend(hb_obj.faces)\n faces.extend(hb_obj.shades)\n else:\n faces.append(hb_obj)\n\n # use the ColorRoom object to get a set of attributes assigned to the faces\n color_obj = ColorFace(faces, _attribute)\n values = color_obj.attributes_unique\n\n # loop through each of the hb_objs and get the floor height\n hb_objs = [[] for val in values]\n for atr, face in zip(color_obj.attributes, color_obj.flat_faces):\n atr_i = values.index(atr)\n hb_objs[atr_i].append(face)\n hb_objs = list_to_data_tree(hb_objs)\n", | ||
"category": "Honeybee", | ||
"name": "HB Faces by Attribute", | ||
"description": "Separate and group Honeybee Faces, Apertures, Doors and Shades by any attribute\nthat the objects possess.\n_\nThis can be used to group faces by construction, modifier, etc.\n-" | ||
} |
61 changes: 34 additions & 27 deletions
61
honeybee_grasshopper_core/json/HB_Rooms_by_Attribute.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,50 @@ | ||
{ | ||
"version": "1.8.0", | ||
"code": "\ntry: # import the core honeybee dependencies\n from honeybee.model import Model\n from honeybee.room import Room\n from honeybee.colorobj import ColorRoom\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the ladybug_{{cad}} dependencies\n \n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, list_to_data_tree\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 # extract any rooms from input Models\n in_rooms = []\n for hb_obj in _rooms:\n if isinstance(hb_obj, Room):\n in_rooms.append(hb_obj)\n elif isinstance(hb_obj, Model):\n in_rooms.extend(hb_obj.rooms)\n else:\n raise TypeError('Expected Room or Model. Got {}.'.format(type(hb_obj)))\n\n # use the ColorRoom object to get a set of attributes assigned to the rooms\n color_obj = ColorRoom(in_rooms, _attribute)\n\n # loop through each of the rooms and get the attributes\n if len(value_) == 0:\n values = color_obj.attributes_unique\n rooms = [[] for val in values]\n for atr, room in zip(color_obj.attributes, in_rooms):\n atr_i = values.index(atr)\n rooms[atr_i].append(room)\n else:\n values = [atr for atr in color_obj.attributes_unique if atr in value_]\n rooms = [[] for val in values]\n for atr, room in zip(color_obj.attributes, in_rooms):\n if atr in values:\n atr_i = values.index(atr)\n rooms[atr_i].append(room)\n rooms = list_to_data_tree(rooms)\n", | ||
"category": "Honeybee", | ||
"inputs": [ | ||
{ | ||
"type": "System.Object", | ||
"name": "_rooms", | ||
"access": "list", | ||
"default": null, | ||
"description": "An array of honeybee Rooms or honeybee Models to be separated\nand grouped based on their attributes." | ||
}, | ||
{ | ||
"type": "string", | ||
"name": "_attribute", | ||
"access": "item", | ||
"default": null, | ||
"description": "Text for the name of the Room attribute with which the\nRooms should be labeled. The Honeybee \"Room Attributes\" component\nlists all of the core attributes of the room. Also, each Honeybee\nextension (ie. Radiance, Energy) includes its own component that\nlists the Room attributes of that extension." | ||
}, | ||
{ | ||
"type": "string", | ||
"name": "value_", | ||
"access": "list", | ||
"default": null, | ||
"description": "An optional value of the attribute that can be used to filter\nthe output rooms. For example, if the input attribute is \"Program\"\na value for the name of a program can be plugged in here\n(eg. \"2019::LargeOffice::OpenOffice\") in order to get only the\nrooms that have this program assigned." | ||
} | ||
], | ||
"nickname": "RoomsByAttr", | ||
"version": "1.8.1", | ||
"outputs": [ | ||
[ | ||
{ | ||
"access": "None", | ||
"name": "values", | ||
"description": "A list of values with one attribute value for each branch of the\noutput rooms.", | ||
"type": null, | ||
"default": null | ||
"name": "values", | ||
"access": "None", | ||
"default": null, | ||
"description": "A list of values with one attribute value for each branch of the\noutput rooms." | ||
}, | ||
{ | ||
"access": "None", | ||
"name": "rooms", | ||
"description": "A data tree of honeybee rooms with each branch of the tree\nrepresenting a different attribute value.", | ||
"type": null, | ||
"default": null | ||
"name": "rooms", | ||
"access": "None", | ||
"default": null, | ||
"description": "A data tree of honeybee rooms with each branch of the tree\nrepresenting a different attribute value." | ||
} | ||
] | ||
], | ||
"inputs": [ | ||
{ | ||
"access": "list", | ||
"name": "_rooms", | ||
"description": "An array of honeybee Rooms or honeybee Models to be separated\nand grouped based on their attributes.", | ||
"type": "System.Object", | ||
"default": null | ||
}, | ||
{ | ||
"access": "item", | ||
"name": "_attribute", | ||
"description": "Text for the name of the Room attribute with which the\nRooms should be labeled. The Honeybee \"Room Attributes\" component\nlists all of the core attributes of the room. Also, each Honeybee\nextension (ie. Radiance, Energy) includes its own component that\nlists the Room attributes of that extension.", | ||
"type": "string", | ||
"default": null | ||
} | ||
], | ||
"subcategory": "2 :: Organize", | ||
"code": "\ntry: # import the core honeybee dependencies\n from honeybee.model import Model\n from honeybee.colorobj import ColorRoom\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the ladybug_{{cad}} dependencies\n \n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, list_to_data_tree\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 # extract any rooms from input Models\n in_rooms = []\n for hb_obj in _rooms:\n if isinstance(hb_obj, Model):\n in_rooms.extend(hb_obj.rooms)\n else:\n in_rooms.append(hb_obj)\n\n # use the ColorRoom object to get a set of attributes assigned to the rooms\n color_obj = ColorRoom(in_rooms, _attribute)\n values = color_obj.attributes_unique\n\n # loop through each of the rooms and get the attributes\n rooms = [[] for val in values]\n for atr, room in zip(color_obj.attributes, in_rooms):\n atr_i = values.index(atr)\n rooms[atr_i].append(room)\n rooms = list_to_data_tree(rooms)\n", | ||
"category": "Honeybee", | ||
"name": "HB Rooms by Attribute", | ||
"description": "Separate and group honeybee Rooms by any attribute that the room possesses.\n_\nThis can be used to group rooms by program, whether rooms are conditioned, etc.\n-" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+368 Bytes
(110%)
honeybee_grasshopper_core/user_objects/HB Faces by Attribute.ghuser
Binary file not shown.
Binary file modified
BIN
+344 Bytes
(110%)
honeybee_grasshopper_core/user_objects/HB Rooms by Attribute.ghuser
Binary file not shown.