Monday, December 01, 2014

Setting Yes No Parameters with Formulas

Peter boards a train in Philadelphia bound for NY. Joe boards a train in NY bound for Philadelphia. If both trains... oh I don't care when their trains pass one another. Next question?

I want Revit to automatically check a Yes/No parameter but only when two other parameters are checked already. I read a post at RFO asking how to accomplish this. That member's issue was Revit complaining about inconsistent units, as it does. I replied that Revit doesn't accept 1 or 0 as a valid true/false value. The formula was written like this for parameter C:

if (and (A,B), 1, 0)

Since Revit doesn't like the 1 or 0 used in that formula we can use this instead:


Revit reads that as, "I (Revit) can only check C if both A and B are checked too". In the Family Types dialog it looks like this.

If I'd like the opposite to happen it looks like this instead:


Revit now reads it as, "I (Revit) can only un-check C if A and B are both checked too." In the Family Types dialog it looks like this.

Greg replied (in the RFO thread) that the formula would accept valid math statements for the true or false result. That means that the formula could be written like this, using the original formula above.

if (and (A,B), 1=1, 0=1)

It looks like this in the Family Types Dialog.

Either approach provides the same end result. Programmers often compete to write the leanest code, complete a task or tasks with the fewest instructions, fewest lines of code. My formula is leaner code but not by much. Regardless, I think it does help to see different solutions to help us solve the problems we encounter later.

No comments: