module BTAP::Geometry::BuildingStoreys
Public Class Methods
auto_assign_spaces_to_stories(model)
click to toggle source
This method will delete any exisiting stories and then try to assign stories based on
the z-axis origin of the space.
# File lib/openstudio-standards/btap/geometry.rb, line 228 def self.auto_assign_spaces_to_stories(model) #delete existing stories. model.getBuildingStorys.sort.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.sort.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)
click to toggle source
override run to implement the functionality of your script model is an OpenStudio::Model::Model, runner is a OpenStudio::Ruleset::UserScriptRunner
# File lib/openstudio-standards/btap/geometry.rb, line 246 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.sort.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.sort.each do |space| space_obj = space[0] space_minz = space[1] if space_obj.buildingStory.empty? story = OpenstudioStandards::Geometry.model_get_building_story_for_nominal_height(model, space_minz) if story.nil? story = OpenStudio::Model::BuildingStory.new(model) story.setNominalZCoordinate(space_minz) story.setName("Building Story #{space_minz.round(1)}m") end space_obj.setBuildingStory(story) end end end