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

Convert a cloned object to the source class

asked 2019-04-25 13:41:46 -0500

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2019-04-25 13:57:45 -0500

updated 2019-04-25 14:02:35 -0500

@Julien Marrec to the rescue!

See his to_actual_object method here:

https://unmethours.com/question/17616...

Oh, also in your case, since addToThermalZone is a ZoneHVACComponent method, you wouldn't necessarily have to cast the cloned ModelObject down to the specific 'actual' object to use it. You could rather just cast to_ZoneHVACComponent.

edit flag offensive delete link more

Comments

Both ways worked, I thought I tried tried the to_ZoneHVACComponent method before but maybe my syntax was wrong.

Luis Lara gravatar imageLuis Lara ( 2019-04-25 14:22:35 -0500 )edit

Your Answer

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

Add Answer

 



Question Tools

1 follower

Stats

Asked: 2019-04-25 13:41:46 -0500

Seen: 43 times

Last updated: Apr 25