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

Best method for creating a ScheduleRule

asked 8 years ago

updated 8 years ago

When creating a schedule via ruby scripts, I create a new ScheduleRuleset object ruleset , then create a ScheduleDay object scheduleDay and finally create the associated ScheduleRule as:

rule = OpenStudio::Model::ScheduleRule.new(ruleset, scheduleDay)

This works just fine but (as indicated in the documentation) the ScheduleDay object is cloned and the new object is associated with the rule. Practically this is fine and the ruleset is created as expected but it leaves these orphaned ScheduleDay objects in the OSM.

My question is, is there a (non-hacky) way to create the ScheduleRules without polluting the OSM with a bunch of unused ScheduleDay objects? Or alternatively, if I create the rule without the ScheduleDay and a new ScheduleDay object is created, how do I access it?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
3

answered 8 years ago

updated 8 years ago

The ScheduleRule API was designed to disallow sharing of DaySchedules. So if you create the DaySchedule first and pass it in, you will have to delete the original yourself. If you use the other constructor (with a ScheduleRuleset but not ScheduleDay) the ScheduleRule will construct its own ScheduleDay. You can get that from the ScheduleRule later and modify it.

Preview: (hide)
link

Comments

Thanks @macumber. How does one access the ScheduleDay that the rule constructs? In the method list for ScheduleRule I'm not seeing a straight forward way to do so; is it necessary to call children() and search for the ScheduleDay?

Sam Currie's avatar Sam Currie  ( 8 years ago )
macumber's avatar macumber  ( 8 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: 8 years ago

Seen: 219 times

Last updated: May 31 '16