Skip to content

Commit

Permalink
fix(create): Don't separate mid for single-story building
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Oct 9, 2024
1 parent 54fdfcd commit 2f69224
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
:dragon: :green_book: Dragonfly plugin for Grasshopper (aka. dragonfly[+]).

This repository contains all Grasshopper components for the dragonfly plugin.
The package includes both the userobjects (`.ghuser`) and the Python source (`.py`).
The package includes both the user objects (`.ghuser`), the Python source (`.py`),
and a JSON version of the grasshopper component data.
Note that this library only possesses the Grasshopper components and, in order to
run the plugin, the core libraries must be installed in a way that they can be
discovered by Rhino (see dependencies).
Expand Down
4 changes: 2 additions & 2 deletions dragonfly_grasshopper/json/DF_Separate_Top_Bottom.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.0",
"version": "1.8.1",
"nickname": "TopBottom",
"outputs": [
[
Expand Down Expand Up @@ -36,7 +36,7 @@
}
],
"subcategory": "0 :: Create",
"code": "\ntry: # import the core honeybee dependencies\n from honeybee.units import parse_distance_string\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the core dragonfly dependencies\n from dragonfly.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly:\\n\\t{}'.format(e))\n\ntry: # import the ladybug_{{cad}} dependencies\n from ladybug_{{cad}}.config import units_system, tolerance\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# tolerance for computing the pole of inaccessibility\np_tol = parse_distance_string('0.01m', units_system())\n\n\ndef split_mid_stories(building):\n \"\"\"Split the middle stories of a building to ensure matching areas.\"\"\"\n for x, story in enumerate(building.unique_stories[:-1]):\n story_above = building.unique_stories[x + 1]\n story.split_with_story_above(story_above, tolerance)\n story.set_top_exposed_by_story_above(story_above, p_tol)\n story.solve_room_2d_adjacency(tolerance, intersect=False)\n\n\nif all_required_inputs(ghenv.Component):\n # get the building objects from the input ones\n buildings = [bldg.duplicate() for bldg in _buildings]\n for bldg in buildings:\n if sep_mid_:\n if isinstance(bldg, Model):\n for b in bldg.buildings:\n b.separate_mid_floors(p_tol)\n if split_mid_:\n split_mid_stories(b)\n else:\n bldg.separate_mid_floors(p_tol)\n if split_mid_:\n split_mid_stories(bldg)\n else:\n bldg.separate_top_bottom_floors()\n",
"code": "\ntry: # import the core honeybee dependencies\n from honeybee.units import parse_distance_string\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the core dragonfly dependencies\n from dragonfly.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly:\\n\\t{}'.format(e))\n\ntry: # import the ladybug_{{cad}} dependencies\n from ladybug_{{cad}}.config import units_system, tolerance\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# tolerance for computing the pole of inaccessibility\np_tol = parse_distance_string('0.01m', units_system())\n\n\ndef split_mid_stories(building):\n \"\"\"Split the middle stories of a building to ensure matching areas.\"\"\"\n for x, story in enumerate(building.unique_stories[:-1]):\n story_above = building.unique_stories[x + 1]\n story.split_with_story_above(story_above, tolerance)\n story.set_top_exposed_by_story_above(story_above, p_tol)\n story.solve_room_2d_adjacency(tolerance, intersect=False)\n\n\nif all_required_inputs(ghenv.Component):\n # get the building objects from the input ones\n buildings = [bldg.duplicate() for bldg in _buildings]\n for bldg in buildings:\n if sep_mid_ and len(bldg) != 1:\n if isinstance(bldg, Model):\n for b in bldg.buildings:\n b.separate_mid_floors(p_tol)\n if split_mid_:\n split_mid_stories(b)\n else:\n bldg.separate_mid_floors(p_tol)\n if split_mid_:\n split_mid_stories(bldg)\n else:\n bldg.separate_top_bottom_floors()\n",
"category": "Dragonfly",
"name": "DF Separate Top Bottom",
"description": "Separate the top and bottom floors of a Building into unique Stories with a multiplier\nof 1 and automatically assign the first story Room2Ds to have a ground contact\nfloor and the top story Room2Ds to have an outdoor-exposed roof.\n_\nThis is particularly helpful when trying to account for the heat exchange of the\ntop or bottom floors with the gound or outdoors.\n_\nThe \"mid\" options can also be used to separate the middle floors and account for\nheat flow through exposed roofs of middle floors.\n-"
Expand Down
4 changes: 2 additions & 2 deletions dragonfly_grasshopper/src/DF Separate Top Bottom.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

ghenv.Component.Name = 'DF Separate Top Bottom'
ghenv.Component.NickName = 'TopBottom'
ghenv.Component.Message = '1.8.0'
ghenv.Component.Message = '1.8.1'
ghenv.Component.Category = 'Dragonfly'
ghenv.Component.SubCategory = '0 :: Create'
ghenv.Component.AdditionalHelpFromDocStrings = '2'
Expand Down Expand Up @@ -80,7 +80,7 @@ def split_mid_stories(building):
# get the building objects from the input ones
buildings = [bldg.duplicate() for bldg in _buildings]
for bldg in buildings:
if sep_mid_:
if sep_mid_ and len(bldg) != 1:
if isinstance(bldg, Model):
for b in bldg.buildings:
b.separate_mid_floors(p_tol)
Expand Down
Binary file modified dragonfly_grasshopper/user_objects/DF Separate Top Bottom.ghuser
Binary file not shown.

0 comments on commit 2f69224

Please sign in to comment.