First time here? Check out the Help page!

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 5 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
4

answered 5 years ago

updated 5 years ago

@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.

Preview: (hide)
link

Comments

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

Luis Lara's avatar Luis Lara  ( 5 years ago )

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 222 times

Last updated: Apr 25 '19