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

Revision history [back]

Convert a cloned object to the source class

I want to clone an existing ZoneHVACComponent (such as a ZoneHVACLowTempRadiantVarFlow or a ZoneHVACWaterToAirHeatPump) and then add it to a thermal zone. However, using the clone method on an object returns a ModelObject and I cannot access the addToThermalZone method in the cloned object unless I use the ".to_#{ClassName}" method to convert it to the same class as the source.

I am looking to be able to use use the ".to_#{ClassName}" method no matter the source object Class without having to specify a case statement or something similar. I could write the full case statement but I feel like there is a more elegant solution.