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.


Unknown said...

Fantastic! Thank you.

Anonymous said...

Thank you. I just read an hour's worth of blog comments and they go on for days about super complex formulas (but no simple ones like this or the alternative is Autodesk help which hardly provides any information.

Unknown said...

This thread came up while I was looking for an answer to a slightly different question. This blog post is looking to give a positive to two positives or a negative to two positives. What I'm looking for is a way to have three or more options and have each exclude the others. So if I want A to be on, I check A. That tells B and C to be off. If I change my mind and want B turned on, I check B - and A and C turn off. I'm sure I'm close to the answer in what's been said in your blog post, but I'm not a programmer so I'm having trouble turning my head upside down and seeing what the answer is. Thanks for any help.

Unknown said...

I tried commenting yesterday, but I didn't see the "notify me" button and I don't see my comment, so I'm trying again. Just delete the redundant effort and accept my apology. And now, on to my question:

I found this thread while looking for something else. This is very promising but it's not quite what I'm looking for. What I'm looking for is a way to make three or more options mutually exclusive of the others. I want checking A to turn off B and C. I want to change my mind, check B, and have A turn off and C remain off. Then I want to do that for C and have B turn off and A stay off. I tried some variations on the above formulas but got slapped by Revit because ...I don't know diddly about programming.

Steve said...

Hi Unknown - This thread/post at RFO (RevitForum) might help you along your way.