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

Converting a OptionalWorkspaceObject to a FanZoneExhaust Object

asked 2021-06-15 17:43:00 -0600

Matthew's avatar

updated 2021-07-01 12:17:38 -0600

Hey all, I am trying to write a measure that assigns end-use subcategories to user-selected Lights and FanZoneExhaust objects. For the Lights object, this is fairly easy, I can just use the following code to convert the OptionalWorkspaceObject to a Lights object.

parking_light = runner.getOptionalWorkspaceObjectChoiceValue("parking_lights_choice", user_arguments, model)

if parking_light.empty?
    handle = runner.getStringArgumentValue("parking_lights_choice",user_arguments)
    if handle.empty?
        runner.registerError("No Light chosen for Parking.")
    else
        runner.registerError("Unable to find Light with handle '#{handle}' in the model")
    end
else
    if not parking_light.get.to_Lights.empty?
        parking_light = parking_light.get.to_Lights.get
        parking_light.setEndUseSubcategory("Parking")
        runner.registerInfo("The new enduse sub-category for light: #{parking_light.lightsDefinition.name} is #{parking_light.endUseSubcategory}")
    else
        runner.registerError("Script Error - parking lights argument not showing up as Lights object")
    end
end

However, when I try to do the same for FanZoneExhaust objects I get an error saying to_FanZoneExhaust is not a valid method (I have also tried to_Fan and to_ZoneExhaust). Am I getting the method name wrong or should I be taking a different approach? Relevant code:

parking_fan_1 = runner.getOptionalWorkspaceObjectChoiceValue("parking_fans_choice", user_arguments, model)

if parking_fan_1.empty?
    handle = runner.getStringArgumentValue("parking_fans_choice",user_arguments)
    if handle.empty?
        runner.registerError("No Fan chosen for Parking.")
    else
        runner.registerError("Unable to find Fan with handle '#{handle}' in the model")
    end
else
    runner.registerInfo("The fan: #{parking_fan_1.class} and #{parking_fan_1.get.class} is #{parking_fan_1.get.to_s}")
    if not parking_fan_1.get.to_ZoneExhausts.empty?
        parking_fan_1 = parking_fan_1.get.to_ZoneExhausts.get
        parking_fan_1.setEndUseSubcategory("Parking")
        runner.registerInfo("The new enduse sub-category for fan: #{parking_fan_1.name} is #{parking_fan_1.endUseSubcategory}")
    else
        runner.registerError("Script Error - parking fan argument not showing up as FanZoneExhausts object")
    end
end
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2021-06-15 17:56:49 -0600

Matthew's avatar

The issue was a typo, the method to_FanZoneExhaust works.

edit flag offensive delete link more

Comments

please mark your answer with the green check mark so we know the issue is resolved :)

sashadf1's avatar sashadf1  ( 2021-06-17 12:54:36 -0600 )edit

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: 2021-06-15 17:43:00 -0600

Seen: 115 times

Last updated: Jun 17 '21