1

Replace a construction in a construction set

I am struggling to replace a construction in a construction set generated via openstudio-standard with a construction extracted from a reference model. I have based my code on this measure, but no success so far.

This is my attempt. First I get my wall construction from an existing model

wall_construction = ref_model.getConstructionByName(wall_construction_name).get

(The construction exists)

then i create a standard object and get its construction set with

bldg_def_const_set = standard.model_add_construction_set(model, climate_zone, building_type, nil, false)

Finally, I try to replace the construction for walls with

if bldg_def_const_set.is_initialized    
  # This is the overall construction set
  bldg_def_const_set = bldg_def_const_set.get
  # This is the exterior surfaces default construction set
  default_ext_surface_const_set = bldg_def_const_set.defaultExteriorSurfaceConstructions.get
  # And now we can assign the wall
  default_ext_surface_const_set.setWallConstruction(wall_construction.to_Construction.get) # Tried also with to_ConstructionBase as in the measure. 

  puts "SAP construction replaced the default construction!"
  building.setDefaultConstructionSet(bldg_def_const_set)
  puts "Success!"
else
  puts "Could not create default construction set for the building."
end

There is no error, but the new construction is not there.

I cannot understand what I am missing. Any idea?

MapMortar's avatar
145
MapMortar
asked 2022-09-26 06:58:33 -0500
Aaron Boranian's avatar
14.1k
Aaron Boranian
updated 2022-09-26 09:31:59 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

3

wall_construction is still just in ref_model you need to clone it to model before you assign it. That would look something like this.

wall_construction = wall_construction.to_Construction.get
wall_construction_clone = wall_construction.clone(model).to_Construction.get
default_ext_surface_const_set.setWallConstruction(wall_construction_clone)
David Goldwasser's avatar
20.4k
David Goldwasser
answered 2022-09-26 10:36:26 -0500, updated 2022-09-26 10:39:38 -0500
edit flag offensive 0 remove flag delete link

Comments

That makes sense. Thanks!

MapMortar's avatar MapMortar (2022-09-26 10:48:32 -0500) edit
add a comment see more comments