Measures/m_5_example_5_computed_schedule/resources/util.rb
# Creates constructions as needed and assigns to surfaces.
# Leave name as nil if the materials (e.g., exterior finish) apply to multiple constructions.
Creates constructions as needed and assigns to surfaces.
Leave name as nil if the materials  apply to multiple constructions.
Creates constructions as needed and assigns to surfaces . Leave name as nil if the materials apply to multiple constructions .
def create_and_assign_constructions(surfaces, runner, model, name=nil)
        if not validated?(runner)
            return false
        end
        materials = construct_materials(model, runner)
        if materials.size == 0 and @remove_materials.size == 0
            return true
        end
        construction_map = {} 
        rev_construction_map = {} 
        surfaces.each do |surface|
            constr_name = nil
            if surface.construction.is_initialized
                constr_name = surface.construction.get.name.to_s
            end
            if not construction_map.include? constr_name
                num_prev_constructions = model.getConstructions.size
                if not create_and_assign_construction(surface, materials, runner, model, name)
                    return false
                end
                if model.getConstructions.size != num_prev_constructions
                    construction_map[constr_name] = surface.construction.get
                    print_construction_creation(runner, surface)
                    print_construction_assignment(runner, surface)
                end
            else
                surface.setConstruction(construction_map[constr_name])
                print_construction_assignment(runner, surface)
            end
            next if surface.is_a? OpenStudio::Model::SubSurface or surface.is_a? OpenStudio::Model::InternalMassDefinition or not surface.adjacentSurface.is_initialized
            if surface.construction.get.name.to_s.start_with?("Rev")
                rev_constr_name = surface.construction.get.name.to_s
                rev_constr_name.slice!(0..2)
            else
                rev_constr_name = "Rev#{surface.construction.get.name.to_s}"
            end
            adjacent_surface = surface.adjacentSurface.get
            if not rev_construction_map.include? rev_constr_name
                num_prev_constructions = model.getConstructions.size
                revconstr = surface.construction.get.to_Construction.get.reverseConstruction
                if model.getConstructions.size != num_prev_constructions
                    revconstr.setName(rev_constr_name)
                end
                adjacent_surface.setConstruction(revconstr)
                rev_construction_map[rev_constr_name] = adjacent_surface.construction.get
                if model.getConstructions.size != num_prev_constructions
                    print_construction_creation(runner, adjacent_surface)
                end
                print_construction_assignment(runner, adjacent_surface)
            else
                adjacent_surface.setConstruction(rev_construction_map[rev_constr_name])
                print_construction_assignment(runner, adjacent_surface)
            end
        end
        return true
    end
def create_and_assign_constructions ( surfaces , runner , model , name = nil ) if not validated? ( runner ) return false end materials = construct_materials ( model , runner ) if materials . size == 0 and @remove_materials . size == 0 return true end construction_map = { } rev_construction_map = { } surfaces . each do | surface | constr_name = nil if surface . construction . is_initialized constr_name = surface . construction . get . name . to_s end if not construction_map . include? constr_name num_prev_constructions = model . getConstructions . size if not create_and_assign_construction ( surface , materials , runner , model , name ) return false end if model . getConstructions . size != num_prev_constructions construction_map [ constr_name ] = surface . construction . get print_construction_creation ( runner , surface ) print_construction_assignment ( runner , surface ) end else surface . setConstruction ( construction_map [ constr_name ] ) print_construction_assignment ( runner , surface ) end next if surface . is_a? OpenStudio :: Model :: SubSurface or surface . is_a? OpenStudio :: Model :: InternalMassDefinition or not surface . adjacentSurface . is_initialized if surface . construction . get . name . to_s . start_with? ( "Rev" ) rev_constr_name = surface . construction . get . name . to_s rev_constr_name . slice! ( 0 .. 2 ) else rev_constr_name = "Rev#{surface.construction.get.name.to_s}" end adjacent_surface = surface . adjacentSurface . get if not rev_construction_map . include? rev_constr_name num_prev_constructions = model . getConstructions . size revconstr = surface . construction . get . to_Construction . get . reverseConstruction if model . getConstructions . size != num_prev_constructions revconstr . setName ( rev_constr_name ) end adjacent_surface . setConstruction ( revconstr ) rev_construction_map [ rev_constr_name ] = adjacent_surface . construction . get if model . getConstructions . size != num_prev_constructions print_construction_creation ( runner , adjacent_surface ) end print_construction_assignment ( runner , adjacent_surface ) else adjacent_surface . setConstruction ( rev_construction_map [ rev_constr_name ] ) print_construction_assignment ( runner , adjacent_surface ) end end return true end
Creates constructions as needed and assigns to surfaces.
Creates constructions as needed and assigns to surfaces .
# Uncomment the following line to debug #print_layers(runner) #runner.registerInfo("Assembly R-value: #{assembly_rvalue(runner).to_s}") # Used to create new constructions only for each existing unique construction # Used for adjacent surfaces, which get reverse constructions # Get construction name, if available # Assign construction to surface # Create new construction # Re-use recently created construction # Assign reverse construction to adjacent surface as needed # Strip "Rev" at beginning # Add "Rev" to beginning # Create adjacent construction # If the reverse construction already found (or the construction has  # only a single layer), we won't get a new construction here. # Re-use recently created adjacent construction
surfaces
<not_specific>
runner
<not_specific>
model
<not_specific>
name
<not_specific>