Module: BTAP::Geometry::BuildingStoreys
- Defined in:
- lib/openstudio-standards/btap/geometry.rb
Class Method Summary collapse
-
.auto_assign_spaces_to_stories(model) ⇒ Object
This method will delete any exisiting stories and then try to assign stories based on the z-axis origin of the space.
-
.auto_assign_stories(model) ⇒ Object
override run to implement the functionality of your script model is an OpenStudio::Model::Model, runner is a OpenStudio::Ruleset::UserScriptRunner.
-
.get_zones_from_storey(storey) ⇒ Object
Get the zones in a storey.
-
.getStoryForNominalZCoordinate(model, minz) ⇒ Object
find the first story with z coordinate, create one if needed.
Class Method Details
.auto_assign_spaces_to_stories(model) ⇒ Object
This method will delete any exisiting stories and then try to assign stories based on the z-axis origin of the space.
2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2192 def self.auto_assign_spaces_to_stories(model) #delete existing stories. model.getBuildingStorys.each {|buildingstory| buildingstory.remove } #create hash of building storeys, index is the Z-axis origin of the space. building_story_hash = Hash.new() model.getSpaces.each do |space| if building_story_hash[space.zOrigin].nil? building_story_hash[space.zOrigin] = OpenStudio::Model::BuildingStory.new(model) building_story_hash[space.zOrigin].setName( building_story_hash.length.to_s ) end space.setBuildingStory(building_story_hash[space.zOrigin]) end end |
.auto_assign_stories(model) ⇒ Object
override run to implement the functionality of your script model is an OpenStudio::Model::Model, runner is a OpenStudio::Ruleset::UserScriptRunner
2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2223 def self.auto_assign_stories(model) # get all spaces spaces = model.getSpaces puts("Assigning Stories to Spaces") # make has of spaces and minz values sorted_spaces = Hash.new spaces.each do |space| # loop through space surfaces to find min z value z_points = [] space.surfaces.each do |surface| surface.vertices.each do |vertex| z_points << vertex.z end end minz = z_points.min + space.zOrigin sorted_spaces[space] = minz end # pre-sort spaces sorted_spaces = sorted_spaces.sort{|a,b| a[1]<=>b[1]} # this should take the sorted list and make and assign stories sorted_spaces.each do |space| space_obj = space[0] space_minz = space[1] if space_obj.buildingStory.empty? story = getStoryForNominalZCoordinate(model, space_minz) #puts("Setting story of Space " + space_obj.name.get + " to " + story.name.get + ".") space_obj.setBuildingStory(story) end end end |
.get_zones_from_storey(storey) ⇒ Object
Get the zones in a storey
2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2209 def self.get_zones_from_storey(storey) #check to see if the storey has a zone that is part of the zone list. zones = Array.new storey.spaces.each do |space| if not space.thermalZone.empty? and not zones.include?(space.thermalZone.get) zones.push( space.thermalZone.get ) end end return zones end |
.getStoryForNominalZCoordinate(model, minz) ⇒ Object
find the first story with z coordinate, create one if needed
2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2262 def self.getStoryForNominalZCoordinate(model, minz) model.getBuildingStorys.each do |story| z = story.nominalZCoordinate if not z.empty? if minz == z.get return story end end end story = OpenStudio::Model::BuildingStory.new(model) story.setNominalZCoordinate(minz) return story end |