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

why the cloned object type changed using the ruby bindings

Hi I want to clone a exist boiler in model by using ruby binding, but after that, I find the modeloject type is diferent, so that I can not add this boiler into a plantloop. how do I change the copy one's object type?

irb(main):115:0> new_boiler = model.getBoilerHotWaters[0].clone(model)
=> #<OpenStudio::Model::ModelObject:0x0000000395a738 @__swigtype__="_p_openstudio__model__ModelObject">
irb(main):116:0> hot_water_loop = model.getPlantLoops[0]
=> #<OpenStudio::Model::PlantLoop:0x0000000390be58 @__swigtype__="_p_openstudio__model__PlantLoop">
irb(main):117:0> hot_water_loop.addSupplyBranchForComponent(new_boiler)
TypeError: Expected argument 1 of type openstudio::model::HVACComponent, but got OpenStudio::Model::ModelObject #<OpenStudio::Model::ModelObje...
        in SWIG method 'addSupplyBranchForComponent'
        from (irb):117:in `addSupplyBranchForComponent'
        from (irb):117
        from C:/Ruby200-x64/bin/irb:12:in `<main>'

the new_boiler is OpenStudio::Model::ModelObject, but the original one is:

irb(main):118:0> model.getBoilerHotWaters[0]
=> #<OpenStudio::Model::BoilerHotWater:0x00000003850ec8 @__swigtype__="_p_openstudio__model__BoilerHotWater">