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.
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.
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# 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) ⇒ Object
override run to implement the functionality of your script model is an OpenStudio::Model::Model, runner is a OpenStudio::Ruleset::UserScriptRunner
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# 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 |