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.
2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2176 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
2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2207 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
2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2193 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
2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 |
# File 'lib/openstudio-standards/btap/geometry.rb', line 2246 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 |