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