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

Revision history [back]

click to hide/show revision 1
initial version

From the Measure Writer's Reference Guide, it have a clear explanation:

"Several methods in OpenStudio return a "ModelObject" (".clone", ".optionalWorkspaceObjectChoiceValue", etc.). This is fine for many purposes; however, if you want to test if the object returned is of a particular type (e.g., is it a Space or a SpaceType), you will have to try converting the object to those types using the ".to_#{ClassName}" (".to_Space", ".to_SpaceType", etc). "

Therefore:

irb(main):128:0> new_boiler = model.getBoilerHotWaters[0].clone(model).to_BoilerHotWater
=> #<OpenStudio::Model::OptionalBoilerHotWater:0x000000037bda88 @__swigtype__="_p_boost__optionalT_openstudio__model__BoilerHotWater_t">
irb(main):129:0> new_boiler = new_boiler.get
=> #<OpenStudio::Model::BoilerHotWater:0x000000039775e0 @__swigtype__="_p_openstudio__model__BoilerHotWater">