Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
1

Why is OptionalBuilding empty & uninitalized for my osm model?

asked 2017-10-15 23:33:31 -0500

antonszilasi's avatar

updated 2017-10-15 23:34:53 -0500

I am attempting to use the ReplaceExteriorWindowConstruction measure, while it is creating a new construction set with the new window it is not actually setting this new construction set as the default construction set and hence the windows are not being replaced in the model.

This is because on the lines 295 to 308 of the measure - the lines of code seen below.

      #link new subset to new set
      new_default_construction_set.setDefaultExteriorSubSurfaceConstructions(new_default_sub_surface_const_set)

      #swap all uses of the old construction set for the new
      construction_set_sources = default_construction_set.sources
      construction_set_sources.each do |construction_set_source|
        building_source = construction_set_source.to_Building
        if not building_source.empty?
          building_source = building_source.get
          building_source.setDefaultConstructionSet(new_default_construction_set)
          next
        end
        #add SpaceType, BuildingStory, and Space if statements

      end #end of construction_set_sources.each do

The variable building source which is an instance of the class OpenStudio::Model::OptionalBuilding is not initalized in my model so it is empty. Hence the part of the code in the if statement which actually changes the default constructions is never run.

So my question is, why is my model not initalized what is going wrong in the code here? You can find my osm model (osm1.osm) and a copy of the measure and tests for the measure here.

Any help is greatly appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-10-16 08:57:56 -0500

updated 2017-10-16 08:59:43 -0500

Your model has a default construction set, but it is referenced by the spaces, not from the building object. So when the code looks for default_construction_set.sources it is not finding any source that can cast to_Building.

If you don't want to change the osm, you can extend that code as implied by the comment #add SpaceType, BuildingStory, and Space if statements, like:

    space_source = construction_set_source.to_Space
    if not space_source.empty?
      space_source = space_source.get
      space_source.setDefaultConstructionSet(new_default_construction_set)
      next
    end
edit flag offensive delete link more

Comments

Thank you @Eric Ringold that worked! How do I contribute my change in the measure back to the community? I don't see a OpenStudio Measure github repo

antonszilasi's avatar antonszilasi  ( 2017-10-16 09:56:53 -0500 )edit

@David Goldwasser can help you out with that.

ericringold's avatar ericringold  ( 2017-10-16 10:00:42 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2017-10-15 23:33:31 -0500

Seen: 69 times

Last updated: Oct 16 '17