Skip to content

Commit

Permalink
Revised PR: Mass2Zones and SplitFloors2ThermalZones bug fixes (#669)
Browse files Browse the repository at this point in the history
Resolved #666 

* Changing component description text to clarify concave/convex use.

* Adding credit to Devang for convex checker in code

* Adding fix to square zone edge case

* saving user object for split2zone

* Duplicate geometries for Mass2Zones component and saving .py and user objects

* changing copying brep from map lambda to copy.deepcopy
  • Loading branch information
saeranv authored and mostaphaRoudsari committed Nov 25, 2017
1 parent 19854ed commit ac9d8f0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 37 deletions.
68 changes: 34 additions & 34 deletions src/Honeybee_Masses2Zones.py
@@ -1,22 +1,22 @@
#
# Honeybee: A Plugin for Environmental Analysis (GPL) started by Mostapha Sadeghipour Roudsari
#
#
# This file is part of Honeybee.
#
# Copyright (c) 2013-2017, Mostapha Sadeghipour Roudsari <mostapha@ladybug.tools>
# Honeybee is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
#
# Copyright (c) 2013-2017, Mostapha Sadeghipour Roudsari <mostapha@ladybug.tools>
# Honeybee is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# Honeybee is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with Honeybee; If not, see <http://www.gnu.org/licenses/>.
#
#
# @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>


Expand Down Expand Up @@ -47,11 +47,11 @@
import System
import Grasshopper.Kernel as gh
import uuid

import copy

ghenv.Component.Name = 'Honeybee_Masses2Zones'
ghenv.Component.NickName = 'Mass2Zone'
ghenv.Component.Message = 'VER 0.0.62\nSEP_24_2017'
ghenv.Component.Message = 'VER 0.0.62\nNOV_24_2017'
ghenv.Component.IconDisplayMode = ghenv.Component.IconDisplayMode.application
ghenv.Component.Category = "Honeybee"
ghenv.Component.SubCategory = "00 | Honeybee"
Expand All @@ -67,13 +67,13 @@
################################################################################

def main(maximumRoofAngle, zoneMasses, zoneNames, zonePrograms, isConditioned):

# check for Honeybee
if not sc.sticky.has_key('honeybee_release'):
msg = "You should first let Honeybee fly..."
ghenv.Component.AddRuntimeMessage(gh.GH_RuntimeMessageLevel.Warning, msg)
return -1

try:
if not sc.sticky['honeybee_release'].isCompatible(ghenv.Component): return -1
if sc.sticky['honeybee_release'].isInputMissing(ghenv.Component): return -1
Expand All @@ -85,22 +85,23 @@ def main(maximumRoofAngle, zoneMasses, zoneNames, zonePrograms, isConditioned):
w = gh.GH_RuntimeMessageLevel.Warning
ghenv.Component.AddRuntimeMessage(w, warning)
return -1

# import the classes
# don't customize this part
hb_EPZone = sc.sticky["honeybee_EPZone"]
hb_EPSrf = sc.sticky["honeybee_EPSurface"]
hb_EPZoneSurface = sc.sticky["honeybee_EPZoneSurface"]

#Have a function to duplicate data.
def duplicateData(data, calcLength):
dupData = []
for count in range(calcLength):
dupData.append(data[0])
return dupData

zoneNumber = len(zoneMasses)

zoneMasses = copy.deepcopy(zoneMasses) # Duplicate the breps so that we don't have same memory access

#If the length of the zonePrograms_ is 1, duplicate it to apply it to all zones. Give a warning if the length of the list does not match the number of zones.
if len(zonePrograms) == 1:
zonePrograms = duplicateData(zonePrograms, zoneNumber)
Expand All @@ -113,7 +114,7 @@ def duplicateData(data, calcLength):
ghenv.Component.AddRuntimeMessage(w, warning)
else:
print "Zones will be assigned a zone program based on the list of connected zonePrograms_."

#If the length of the isConditioned_ is 1, duplicate it to apply it to all zones. Give a warning if the length of the list does not match the number of zones.
if len(isConditioned) == 1:
isConditioned = duplicateData(isConditioned, zoneNumber)
Expand All @@ -126,7 +127,7 @@ def duplicateData(data, calcLength):
ghenv.Component.AddRuntimeMessage(w, warning)
else:
print "Zones will be assigned an isConditioned value based on the list of connected isConditioned_ list."

#Give a warning if the length of the zoneNames_ list does not match the number of zones.
if len(zoneNames) == 0:
print "No value connected for zoneNames_. All zones will be assigned a default name based on their order in the list."
Expand All @@ -141,7 +142,7 @@ def duplicateData(data, calcLength):
ghenv.Component.AddRuntimeMessage(w, warning)
else:
print "Zones will be assigned a zoneName based on the list of connected zoneName_ list."

HBZones = []
# create zones out of masses
for zoneKey, zone in enumerate(zoneMasses):
Expand All @@ -150,36 +151,35 @@ def duplicateData(data, calcLength):
except:
zoneName = "zone_" + str(sc.sticky["hBZoneCount"])
sc.sticky["hBZoneCount"] += 1

# zone programs
try: thisZoneProgram = zonePrograms[zoneKey].split("::")
except: thisZoneProgram = 'Office', 'OpenOffice'

try: isZoneConditioned = isConditioned[zoneKey]
except: isZoneConditioned = True

thisZone = hb_EPZone(zone, zoneKey, zoneName, thisZoneProgram, isZoneConditioned)

# assign surface types and construction based on type
thisZone.decomposeZone(maximumRoofAngle)

# append this zone to other zones
HBZones.append(thisZone)

return HBZones

################################################################################################


if _createHBZones == True and len(_zoneMasses)!=0 and _zoneMasses[0]!=None:

try: maximumRoofAngle = float(maxRoofAngle_)
except: maximumRoofAngle = 30

result= main(maximumRoofAngle, _zoneMasses, zoneNames_, zonePrograms_,isConditioned_)

if result!=-1:
zoneClasses = result
zoneClasses = result
hb_hive = sc.sticky["honeybee_Hive"]()
HBZones = hb_hive.addToHoneybeeHive(zoneClasses, ghenv.Component)

13 changes: 10 additions & 3 deletions src/Honeybee_SplitFloor2ThermalZones.py
Expand Up @@ -23,7 +23,7 @@
"""
Use this component to divide up a brep (polysurface) representative of a building floor into smaller volumes that roughly correspond to how a generic EnergyPlus model should be zoned.
This zoning divide up each floor into a core and perimeter zones, which helps account for the different microclimates you would get on each of the different orientations of a building.
Note: Currently in this WIP convex mainly convex geometry can be handled. Most concave geometries will fail, and any shapes with holes in them will fail. You should therefore prepare the
Note: This component is intended mainly for convex geometry. Most concave geometries will fail, and any shapes with holes in them will fail. You should therefore prepare the
massing of your building by dividing it into convex volumes before using this component.
_
If you have a single mass representing two towers off of a podium, the two towers are not a continuous mass and you should therefore send each tower and the podium in as a separate Brep into this component.
Expand All @@ -49,7 +49,7 @@

ghenv.Component.Name = 'Honeybee_SplitFloor2ThermalZones'
ghenv.Component.NickName = 'Split2Zone'
ghenv.Component.Message = 'VER 0.0.62\nNOV_08_2017'
ghenv.Component.Message = 'VER 0.0.62\nNOV_23_2017'
ghenv.Component.IconDisplayMode = ghenv.Component.IconDisplayMode.application
ghenv.Component.Category = "Honeybee"
ghenv.Component.SubCategory = "00 | Honeybee"
Expand Down Expand Up @@ -2101,6 +2101,12 @@ def debug_LAV_links(LAV):
for i in xrange(len(loc)):
cycle = loc[i]
ptlst = map(lambda n: n.value,cycle)

# This is to deal with degenerate polygons (just two lines) by making it into a triangle
# Could be a better solution for this.
if len(ptlst) < 4:
ptlst.append(ptlst[0])

per_crv = rc.Geometry.Curve.CreateControlPointCurve(ptlst,1)
per_extrusion = rc.Geometry.Extrusion.Create(per_crv,self.ht-self.cpt[2],True)
per_brep = per_extrusion.ToBrep()
Expand Down Expand Up @@ -2179,7 +2185,8 @@ def main(mass, _perimeterZoneDepth):
def checkNonConvex(breps):
"""
Temporary until I get the concave section working!
Code from https://github.com/mostaphaRoudsari/honeybee/blob/master/src/Honeybee_Find%20Non-Convex.py
Credit to Devang Chauhan for code from:
https://github.com/mostaphaRoudsari/honeybee/blob/master/src/Honeybee_Find%20Non-Convex.py
"""
#import the classes
if sc.sticky.has_key('honeybee_release'):
Expand Down
Binary file modified userObjects/Honeybee_Masses2Zones.ghuser
Binary file not shown.
Binary file modified userObjects/Honeybee_SplitFloor2ThermalZones.ghuser
Binary file not shown.

0 comments on commit ac9d8f0

Please sign in to comment.