Revit Families 402 – Greater Than or Equal To
by Tim Alatorre
-
Posted on April 13, 2011
-
Revit, Revit 2010, Revit 2011, Revit 2012, Revit Families, Revit Formulas
As discussed in “Revit Families 103 – Formula Basics” there is no native function in Revit for Greater Than or Equal to (>=) and it’s brother Less Than or Equal to (<=). That’s no problem. With the basic conditional statements we can recreate them.
Greater Than or Equal to (>=)
What we want to do:
If (ParameterA >= ParamaterB, <true>, <false>)
How we do it:
If(not(ParameterA < ParamaterB), <true>, <false>)
Less Than or Equal to (<=)
What we want to do:
If (ParameterA <= ParamaterB, <true>, <false>)
How we do it:
If(not(ParameterA > ParamaterB), <true>, <false>)
Find the Greatest of Three Values
Now that we know how to do greater than or equal to, what if you have three parameters and you want to know the largest of them?
ParamaterA
ParameterB
ParameterC
What we want to do:
Return the largest number, ParameterA, ParamaterB, or ParamaterC
How we do it:
if( and( not( ParameterA < ParameterB), not(ParameterA < ParameterC)), ParameterA, if( and( not( ParameterB < ParameterA), not( ParameterB < ParameterC)), ParameterB, if( and( not( ParameterC < ParameterA), not( ParameterC < ParameterB)), ParameterC, 0)))
The “0” at the end should be replaced with a value that has the same units as your other parameters. ie. feet, mm, etc.
I would just copy and paste that into my family but let me make that easier to understand:
As you can see the logic is pretty straight forward, the >= are taken from what we learned at the top of this post (we do the logical inverse: if it’s not less than). Now that you understand it you can easily find the largest value of two, three, or one hundred different values! Hopefully, someday, Revit will just include a nice easy way to do this.
I have enjoyed looking through all the discussions on your website. This particular discussion “Revit Families 402: Greater Than or Equal To” caught my attention. I am always looking for better ways to parameterize my families.
Not sure how you got this to work “If(not(ParameterA < ParamaterB), , )”.
Your formula does not appear to test for equality as the discussion implies. I used a simple CheckBox method to test it, that way it’s just produced true or false. So I stripped the “Implied” pieces out of the formula for a CheckBox. Upon doing so, your formula failed when both parameters are equal.
To get the parameter to test for greater/less than AND equality, my formula for a CheckBox had to appear like:
and(not(TypeA < TypeB), not(TypeA = TypeB))
TypeA = 1' 0"
TypeB = 1' 0"
Using this method, the check box remained unchecked until TypeA was greater than AND not equal to TypeB. This was the only way I found to truely check for greater/less than and equality. Your method was great for determining the largest or smallest value of a set of parameters.
Edited: I guess depending on what your needs are your method works in most applications. Feel free to explain incase I have missed something. Thank you.
Jason,
Thanks for the comment. I’m glad that these posts have some usefulness.
All of the formula in the post work for me. I’m using Revit 2011 and the formula return “true” when equal. I’ll try it on the latest release and get back to you.