openstudiocore/sketchup_plugin/openstudio/sketchup_plugin/user_scripts/On Demand Template Generators/resources/ConstructionSetGenerator.rb
# pass in the climate zone set here
pass in the climate zone set here
pass in the climate zone set here
def generate_construction_set(template, clim, building_type, spc_type, model = nil)
  if model.nil?
    model = OpenStudio::Model::Model.new
  end
  puts "generating construction set: #{template}-#{clim}-#{building_type}-#{spc_type}"
  data = nil
  if tmp1 = @construction_sets[template]
    if tmp2 = tmp1[clim]
      if tmp3 = tmp2[building_type]
        data = tmp3[spc_type]
      end
    end
  end
  if not data
    puts "Cannot find construction set for #{template} #{clim} #{building_type} #{spc_type}"
    exit
  end
  name = make_name(template, clim, building_type, spc_type)
  construction_set = OpenStudio::Model::DefaultConstructionSet.new(model)
  construction_set.setName(name)
  exterior_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(model)
  construction_set.setDefaultExteriorSurfaceConstructions(exterior_surfaces)
  if construction_name = data["exterior_floor"]
    exterior_surfaces.setFloorConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["exterior_wall"]
    exterior_surfaces.setWallConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["exterior_roof"]
    exterior_surfaces.setRoofCeilingConstruction(get_construction(construction_name, model))
  end
  interior_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(model)
  construction_set.setDefaultInteriorSurfaceConstructions(interior_surfaces)
  if construction_name = data["interior_floor"]
    interior_surfaces.setFloorConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["interior_wall"]
    interior_surfaces.setWallConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["interior_ceiling"]
    interior_surfaces.setRoofCeilingConstruction(get_construction(construction_name, model))
  end
  ground_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(model)
  construction_set.setDefaultGroundContactSurfaceConstructions(ground_surfaces)
  if construction_name = data["ground_contact_floor"]
    ground_surfaces.setFloorConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["ground_contact_wall"]
    ground_surfaces.setWallConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["ground_contact_ceiling"]
    ground_surfaces.setRoofCeilingConstruction(get_construction(construction_name, model))
  end
  exterior_subsurfaces = OpenStudio::Model::DefaultSubSurfaceConstructions.new(model)
  construction_set.setDefaultExteriorSubSurfaceConstructions(exterior_subsurfaces)
  if construction_name = data["exterior_fixed_window"]
    exterior_subsurfaces.setFixedWindowConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["exterior_operable_window"]
    exterior_subsurfaces.setOperableWindowConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["exterior_door"]
    exterior_subsurfaces.setDoorConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["exterior_glass_door"]
    exterior_subsurfaces.setGlassDoorConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["exterior_overhead_door"]
    exterior_subsurfaces.setOverheadDoorConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["exterior_skylight"]
    exterior_subsurfaces.setOverheadDoorConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["tubular_daylight_dome"]
    exterior_subsurfaces.setTubularDaylightDomeConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["tubular_daylight_diffuser"]
    exterior_subsurfaces.setTubularDaylightDiffuserConstruction(get_construction(construction_name, model))
  end
  interior_subsurfaces = OpenStudio::Model::DefaultSubSurfaceConstructions.new(model)
  construction_set.setDefaultInteriorSubSurfaceConstructions(interior_subsurfaces)
  if construction_name = data["interior_fixed_window"]
    interior_subsurfaces.setFixedWindowConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["interior_operable_window"]
    interior_subsurfaces.setOperableWindowConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["interior_door"]
    interior_subsurfaces.setDoorConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["interior_partition"]
    construction_set.setInteriorPartitionConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["space_shading"]
    construction_set.setSpaceShadingConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["building_shading"]
    construction_set.setBuildingShadingConstruction(get_construction(construction_name, model))
  end
  if construction_name = data["site_shading"]
    construction_set.setSiteShadingConstruction(get_construction(construction_name, model))
  end
  construction_set_component = construction_set.createComponent
  return [construction_set, construction_set_component]
end
def generate_construction_set ( template , clim , building_type , spc_type , model = nil ) if model . nil? model = OpenStudio :: Model :: Model . new end puts "generating construction set: #{template}-#{clim}-#{building_type}-#{spc_type}" data = nil if tmp1 = @construction_sets [ template ] if tmp2 = tmp1 [ clim ] if tmp3 = tmp2 [ building_type ] data = tmp3 [ spc_type ] end end end if not data puts "Cannot find construction set for #{template} #{clim} #{building_type} #{spc_type}" exit end name = make_name ( template , clim , building_type , spc_type ) construction_set = OpenStudio :: Model :: DefaultConstructionSet . new ( model ) construction_set . setName ( name ) exterior_surfaces = OpenStudio :: Model :: DefaultSurfaceConstructions . new ( model ) construction_set . setDefaultExteriorSurfaceConstructions ( exterior_surfaces ) if construction_name = data [ "exterior_floor" ] exterior_surfaces . setFloorConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "exterior_wall" ] exterior_surfaces . setWallConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "exterior_roof" ] exterior_surfaces . setRoofCeilingConstruction ( get_construction ( construction_name , model ) ) end interior_surfaces = OpenStudio :: Model :: DefaultSurfaceConstructions . new ( model ) construction_set . setDefaultInteriorSurfaceConstructions ( interior_surfaces ) if construction_name = data [ "interior_floor" ] interior_surfaces . setFloorConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "interior_wall" ] interior_surfaces . setWallConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "interior_ceiling" ] interior_surfaces . setRoofCeilingConstruction ( get_construction ( construction_name , model ) ) end ground_surfaces = OpenStudio :: Model :: DefaultSurfaceConstructions . new ( model ) construction_set . setDefaultGroundContactSurfaceConstructions ( ground_surfaces ) if construction_name = data [ "ground_contact_floor" ] ground_surfaces . setFloorConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "ground_contact_wall" ] ground_surfaces . setWallConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "ground_contact_ceiling" ] ground_surfaces . setRoofCeilingConstruction ( get_construction ( construction_name , model ) ) end exterior_subsurfaces = OpenStudio :: Model :: DefaultSubSurfaceConstructions . new ( model ) construction_set . setDefaultExteriorSubSurfaceConstructions ( exterior_subsurfaces ) if construction_name = data [ "exterior_fixed_window" ] exterior_subsurfaces . setFixedWindowConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "exterior_operable_window" ] exterior_subsurfaces . setOperableWindowConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "exterior_door" ] exterior_subsurfaces . setDoorConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "exterior_glass_door" ] exterior_subsurfaces . setGlassDoorConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "exterior_overhead_door" ] exterior_subsurfaces . setOverheadDoorConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "exterior_skylight" ] exterior_subsurfaces . setOverheadDoorConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "tubular_daylight_dome" ] exterior_subsurfaces . setTubularDaylightDomeConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "tubular_daylight_diffuser" ] exterior_subsurfaces . setTubularDaylightDiffuserConstruction ( get_construction ( construction_name , model ) ) end interior_subsurfaces = OpenStudio :: Model :: DefaultSubSurfaceConstructions . new ( model ) construction_set . setDefaultInteriorSubSurfaceConstructions ( interior_subsurfaces ) if construction_name = data [ "interior_fixed_window" ] interior_subsurfaces . setFixedWindowConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "interior_operable_window" ] interior_subsurfaces . setOperableWindowConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "interior_door" ] interior_subsurfaces . setDoorConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "interior_partition" ] construction_set . setInteriorPartitionConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "space_shading" ] construction_set . setSpaceShadingConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "building_shading" ] construction_set . setBuildingShadingConstruction ( get_construction ( construction_name , model ) ) end if construction_name = data [ "site_shading" ] construction_set . setSiteShadingConstruction ( get_construction ( construction_name , model ) ) end construction_set_component = construction_set . createComponent return [ construction_set , construction_set_component ] end
pass in the climate zone set here
pass in the climate zone set here
#create a new space type and name it # exterior surfaces constructions # interior surfaces constructions # ground contact surfaces constructions # exterior sub surfaces constructions # interior sub surfaces constructions # other constructions #componentize the construction set #return the construction set and the componentized construction set
template
<not_specific>
clim
<not_specific>
building_type
<not_specific>
spc_type
<not_specific>
model
<not_specific>