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

Revision history [back]

Best method for creating a ScheduleRule

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?

Best method for creating a ScheduleRule

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?