December 04, 2020

Revit: Text Parameter Value Driven by Four or More Yes/No Parameters

Regarding my last post, I would be remiss if I did not point out that FAIR59 also replied, with a more elegant solution that is also easier to expand to 5, 6 or more parameters. Check out that post here.

December 01, 2020

Revit: Text Parameter Value Driven by Four Yes/No Parameters

I came across an interesting request in the Autodesk Revit Architecture forum the other day. The person wanted to have four Yes/No parameters (called A, B, C and D) determine the value of a text parameter (called TEXT), based on the following conditions:
  1. If two or more of the four Yes/No parameters are checked, the value of TEXT is to be "SELECT ANY ONE".
  2. If none of the four Yes/No parameters are checked, the value of TEXT is to be "NO TEXT".
  3. If only the A parameter is checked, the value of TEXT is to be "A".
  4. If only the B parameter is checked, the value of TEXT is to be "B".
  5. If only the C parameter is checked, the value of TEXT is to be "C".
  6. If only the D parameter is checked, the value of TEXT is to be "D".

The solution I devised uses a series of nested if statements to work through all of the possibilities. The condition of the first if statement is an or. Each item in the or is an and of a pair of the Yes/No parameters. There is an and for each possible combination of the four Yes/No parameters. If both items in at least one of the combinations of Yes/No parameters is true, then the entire or evaluates to true. That takes care of all of the situations where two or more of the Yes/No parameters are checked, and "SELECT ANY ONE" is returned.

The else of the first condition then launches a series of if statements that tests whether a given Yes/No parameter is checked, starting with A. If A is checked, "A" is returned; if not, another if statement tests for a check in B. If B is checked, "B" is returned, and so on through to D. If D is checked, "D" is returned; if not, "NO TEXT" is returned.

Here is the formula:
if(or(and(A, B), and(A, C), and(A, D), and(B, C), and(B, D), and(C, D)), "SELECT ANY ONE", if(A, "A", if(B, "B", if(C, "C", if(D, "D", "NO TEXT")))))

And a screen capture: