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

Revision history [back]

Change ChoiceArgument parameters based on user input

I am trying to allow a user to select from two dropdowns, but I want the argument of the second dropdown to be filtered based on the input of the user in the first dropdown. A simplified example would be:

states_hash = ['Texas' => ['red', 'blue'], 'Oklahoma' => ['green', 'purple']]

# adding argument for state
state = OpenStudio::Measure::OSArgument.makeChoiceArgument('state', states_hash.keys, true)
state.setDisplayName('State')
state.setDefaultValue('Texas')
args << state

# adding argument for color
color = OpenStudio::Measure::OSArgument.makeChoiceArgument('color', states_array[state], true)
color.setDisplayName('Color')
args << color

The first argument computes fine, but for the second one, states_array[state] is empty because (I believe) that when the measure loads, state is nil. Any ideas?