diff --git a/dragonfly_grasshopper/icon/DF Detailed Windows.png b/dragonfly_grasshopper/icon/DF Detailed Windows.png index 69d71e6..0227b29 100644 Binary files a/dragonfly_grasshopper/icon/DF Detailed Windows.png and b/dragonfly_grasshopper/icon/DF Detailed Windows.png differ diff --git a/dragonfly_grasshopper/json/DF_Detailed_Windows.json b/dragonfly_grasshopper/json/DF_Detailed_Windows.json index f202a67..534dee1 100644 --- a/dragonfly_grasshopper/json/DF_Detailed_Windows.json +++ b/dragonfly_grasshopper/json/DF_Detailed_Windows.json @@ -1,5 +1,5 @@ { - "version": "1.8.0", + "version": "1.8.1", "nickname": "DetailedWindows", "outputs": [ [ @@ -23,13 +23,20 @@ { "access": "list", "name": "_windows", - "description": "A list of Breps that will be added to the input _df_objs as\ndetailed windows.", + "description": "A list of Breps that will be added to the input _df_objs as detailed\nwindows. This can also be a list of orphaned Honeybee Apertures and/or\nDoors to be added to the Dragonfly objects. In the case of Doors, they\nwill be assigned to the Dragonfly object as such.", "type": "System.Object", "default": null + }, + { + "access": "item", + "name": "project_dist_", + "description": "An optional number to be used to project the Aperture/Door geometry\nonto parent Faces. If specified, then sub-faces within this distance\nof the parent Face will be projected and added. Otherwise,\nApertures/Doors will only be added if they are coplanar with a parent Face.", + "type": "double", + "default": null } ], "subcategory": "0 :: Create", - "code": "\ntry: # import the core dragonfly dependencies\n from dragonfly.windowparameter import DetailedWindows\n from dragonfly.model import Model\n from dragonfly.building import Building\n from dragonfly.story import Story\n from dragonfly.room2d import Room2D\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\n from ladybug_{{cad}}.config import tolerance, angle_tolerance\n from ladybug_{{cad}}.togeometry import to_face3d\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 # duplicate the initial objects and convert windows to Face3D\n df_objs = [obj.duplicate() for obj in _df_objs]\n win_geo = [f for geo in _windows for f in to_face3d(geo)]\n\n # collect all of the Room2Ds in the connected dragonfly objects\n room_2ds = []\n for df_obj in df_objs:\n if isinstance(df_obj, Model):\n room_2ds.extend(df_obj.room_2ds)\n elif isinstance(df_obj, Building):\n room_2ds.extend(df_obj.unique_room_2ds)\n elif isinstance(df_obj, Story):\n room_2ds.extend(df_obj.room_2ds)\n elif isinstance(df_obj, Room2D):\n room_2ds.append(df_obj)\n\n # assign the relevant geometries to the Room2Ds\n for room in room_2ds:\n new_win_pars = []\n for seg, win_par in zip(room.floor_segments, room.window_parameters):\n win_to_add = []\n for geo in win_geo:\n if DetailedWindows.is_face3d_in_segment_plane(\n geo, seg, room.floor_to_ceiling_height,\n tolerance, angle_tolerance):\n win_to_add.append(geo)\n if len(win_to_add) != 0:\n det_win = DetailedWindows.from_face3ds(win_to_add, seg)\n new_win_pars.append(det_win)\n else:\n new_win_pars.append(win_par)\n room.window_parameters = new_win_pars\n", + "code": "\ntry: # import the core dragonfly dependencies\n from dragonfly.windowparameter import DetailedWindows\n from dragonfly.model import Model\n from dragonfly.building import Building\n from dragonfly.story import Story\n from dragonfly.room2d import Room2D\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly:\\n\\t{}'.format(e))\n\ntry: # import the core honeybee dependencies\n from honeybee.aperture import Aperture\n from honeybee.door import Door\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\n from ladybug_{{cad}}.config import tolerance, angle_tolerance\n from ladybug_{{cad}}.togeometry import to_face3d\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 # duplicate the initial objects and convert windows to sub-faces\n df_objs = [obj.duplicate() for obj in _df_objs]\n win_geo = []\n for geo in _windows:\n if isinstance(geo, (Aperture, Door)):\n win_geo.append(geo)\n else:\n for f in to_face3d(geo):\n win_geo.append(Aperture('Dummy_Ap', f))\n project_dist = 0 if project_dist_ is None else project_dist_\n\n # collect all of the Room2Ds in the connected dragonfly objects\n room_2ds = []\n for df_obj in df_objs:\n if isinstance(df_obj, Model):\n room_2ds.extend(df_obj.room_2ds)\n elif isinstance(df_obj, Building):\n room_2ds.extend(df_obj.unique_room_2ds)\n elif isinstance(df_obj, Story):\n room_2ds.extend(df_obj.room_2ds)\n elif isinstance(df_obj, Room2D):\n room_2ds.append(df_obj)\n\n # assign the relevant geometries to the Room2Ds\n for room in room_2ds:\n room.assign_sub_faces(win_geo, project_dist, tolerance=tolerance,\n angle_tolerance=angle_tolerance)\n", "category": "Dragonfly", "name": "DF Detailed Windows", "description": "Add detailed window geometries to Dragonfly Room2Ds.\n-" diff --git a/dragonfly_grasshopper/src/DF Detailed Windows.py b/dragonfly_grasshopper/src/DF Detailed Windows.py index 290b84e..f3db3f3 100644 --- a/dragonfly_grasshopper/src/DF Detailed Windows.py +++ b/dragonfly_grasshopper/src/DF Detailed Windows.py @@ -14,8 +14,14 @@ Args: _df_objs: A Dragonfly Model, Building, Story or Room2D, to which the _windows should be added. - _windows: A list of Breps that will be added to the input _df_objs as - detailed windows. + _windows: A list of Breps that will be added to the input _df_objs as detailed + windows. This can also be a list of orphaned Honeybee Apertures and/or + Doors to be added to the Dragonfly objects. In the case of Doors, they + will be assigned to the Dragonfly object as such. + project_dist_: An optional number to be used to project the Aperture/Door geometry + onto parent Faces. If specified, then sub-faces within this distance + of the parent Face will be projected and added. Otherwise, + Apertures/Doors will only be added if they are coplanar with a parent Face. Returns: report: Reports, errors, warnings, etc. @@ -24,7 +30,7 @@ ghenv.Component.Name = "DF Detailed Windows" ghenv.Component.NickName = 'DetailedWindows' -ghenv.Component.Message = '1.8.0' +ghenv.Component.Message = '1.8.1' ghenv.Component.Category = "Dragonfly" ghenv.Component.SubCategory = '0 :: Create' ghenv.Component.AdditionalHelpFromDocStrings = "5" @@ -38,6 +44,12 @@ except ImportError as e: raise ImportError('\nFailed to import dragonfly:\n\t{}'.format(e)) +try: # import the core honeybee dependencies + from honeybee.aperture import Aperture + from honeybee.door import Door +except ImportError as e: + raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e)) + try: from ladybug_rhino.grasshopper import all_required_inputs from ladybug_rhino.config import tolerance, angle_tolerance @@ -47,9 +59,16 @@ if all_required_inputs(ghenv.Component): - # duplicate the initial objects and convert windows to Face3D + # duplicate the initial objects and convert windows to sub-faces df_objs = [obj.duplicate() for obj in _df_objs] - win_geo = [f for geo in _windows for f in to_face3d(geo)] + win_geo = [] + for geo in _windows: + if isinstance(geo, (Aperture, Door)): + win_geo.append(geo) + else: + for f in to_face3d(geo): + win_geo.append(Aperture('Dummy_Ap', f)) + project_dist = 0 if project_dist_ is None else project_dist_ # collect all of the Room2Ds in the connected dragonfly objects room_2ds = [] @@ -65,17 +84,5 @@ # assign the relevant geometries to the Room2Ds for room in room_2ds: - new_win_pars = [] - for seg, win_par in zip(room.floor_segments, room.window_parameters): - win_to_add = [] - for geo in win_geo: - if DetailedWindows.is_face3d_in_segment_plane( - geo, seg, room.floor_to_ceiling_height, - tolerance, angle_tolerance): - win_to_add.append(geo) - if len(win_to_add) != 0: - det_win = DetailedWindows.from_face3ds(win_to_add, seg) - new_win_pars.append(det_win) - else: - new_win_pars.append(win_par) - room.window_parameters = new_win_pars + room.assign_sub_faces(win_geo, project_dist, tolerance=tolerance, + angle_tolerance=angle_tolerance) diff --git a/dragonfly_grasshopper/user_objects/DF Detailed Windows.ghuser b/dragonfly_grasshopper/user_objects/DF Detailed Windows.ghuser index 5f49ac9..52effc0 100644 Binary files a/dragonfly_grasshopper/user_objects/DF Detailed Windows.ghuser and b/dragonfly_grasshopper/user_objects/DF Detailed Windows.ghuser differ