Revit Architecture

Reply
Contributor
jmqrsq
Posts: 16
Registered: ‎10-31-2011
Message 1 of 10 (599 Views)
Accepted Solution

if and conditional formula help

599 Views, 9 Replies
01-15-2013 08:16 AM

is there a way to make a if and conditional statement formula in a family with 3 tests?

 

For example,

 

Behind Furniture, Biscuit, Masonry Wall, Hard Ceiling are all yes/no parameters

 

if(and(Behind Furniture, Biscuit, Hard Ceiling), 0'  0 5/16", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", 0'  0 27/256", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256"))))

 

what is wrond with my formula?

 

I am trying to change a dimension  based on what yes/no parameters are checked. It keeps telling me that its "a bad if statement format". It works fine for the first teo dimension tests but when I add this last one I get the error. I need the 3rd dimension to check against 3 yes/no parameters all being = yes before moving on to the next check. I would appreciate the advanced help here.

I'll give you two methods to achieve this:

 

#1 - OR/AND method (typically better when fewer parameters are involved):

if(and(Behind Furniture, Biscuit, Masonry Wall), 0'  0 5/16", if(or(and(Behind Furniture, Biscuit), and(Behind Furniture, Masonry Wall), and(Biscuit, Masonry Wall)), 0'  0 31/128", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256")))))

 

#2 - IF/SUM method (typically better when many parameters are involved):

if(and(Behind Furniture, Biscuit, Masonry Wall), 0'  0 5/16", if(if(Behind Furniture, 1, 0) + if(Biscuit, 1, 0) + if(Masonry Wall, 1, 0) = 2, 0'  0 31/128", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256")))))

 

Just ask if you have any more questions or if you'd like me to elaborate!

Thanks! I figured one way to do it although I was sure there had to be an easier and shorter way to do it:

 

if(and(Behind Furniture, Biscuit, Masonry Wall), 0'  0 5/16", if(and(Behind Furniture, Biscuit), 0'  0 31/128", if(and(Behind Furniture, Masonry Wall), 0'  0 31/128", if(and(Biscuit, Masonry Wall), 0'  0 31/128", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256")))))))

 

I was wondering if you could combine a if or & and conditional statement or not. I tried to do a search on Google but really wasnt sure what this would be called to use for keywords in my search. =) I will try to decipher what is going on in the examples you suggested to simplify any future formulas I do like this one. Any further explanation would be welcomed by me and any other person who stumbles accross this post.

 

Cheers!

To elaborate a little:

 


CADastrophe wrote:

#1 - OR/AND method (typically better when fewer parameters are involved):

if(and(Behind Furniture, Biscuit, Masonry Wall), 0'  0 5/16", if(or(and(Behind Furniture, Biscuit), and(Behind Furniture, Masonry Wall), and(Biscuit, Masonry Wall)), 0'  0 31/128", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256")))))


if(

  or(    < this means that if ANY of the conditional statements below return TRUE, then this returns TRUE

     and(Behind Furniture, Biscuit),               < each of these conditional statements tests

     and(Behind Furniture, Masonry Wall),     every combination of the YES/NO Parameters

     and(Biscuit, Masonry Wall)                         and will return TRUE if two of them are YES.

     )

  , 0'  0 31/128",                             < This is the result return if the OR statement is TRUE

   ,[the remainder of your formula]  < otherwise, it resorts to the remainder of the formula.

 )

 


CADastrophe wrote:

#2 - IF/SUM method (typically better when many parameters are involved):

if(and(Behind Furniture, Biscuit, Masonry Wall), 0'  0 5/16", if(if(Behind Furniture, 1, 0) + if(Biscuit, 1, 0) + if(Masonry Wall, 1, 0) = 2, 0'  0 31/128", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256")))))


if(

  if(Behind Furniture, 1, 0)   < each of these statements test each YES/NO Parameter and returns 1 for YES, 0 for NO.

  +

  if(Biscuit, 1, 0),

  +                         < These results, which will either be 1 or 0, are added together to form the first part of the conditional statement

  if(Masonry Wall, 1, 0),

  = 2

  , 0'  0 31/128",                             < This is the result return if the above statement is true, meaning that the sum of the IF's is 2

   ,[the remainder of your formula]  < otherwise, it resorts to the remainder of the formula.

 )

 

 

Hope this is clear enough!

Contributor
jmqrsq
Posts: 16
Registered: ‎10-31-2011
Message 2 of 10 (596 Views)

Re: if and conditional formula help

01-15-2013 08:24 AM in reply to: jmqrsq

Ok so I realize what I had wrong there:

 

if(and(Behind Furniture, Biscuit, Masonry Wall), 0'  0 5/16", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256"))))

 

worked. But now I need the formula to check if any two yes/no parameters = yes then 31/128", if none = yes then 27/256"

 

Using my parameters mentioned earlier is it possible to achieve what I want to do? If so, then how can I fix this? Myabe there is an easier way?

 

Again, I appreciate the help!

*Expert Elite*
CADastrophe
Posts: 3,286
Registered: ‎08-28-2009
Message 3 of 10 (586 Views)

Re: if and conditional formula help

01-15-2013 08:43 AM in reply to: jmqrsq

I'll give you two methods to achieve this:

 

#1 - OR/AND method (typically better when fewer parameters are involved):

if(and(Behind Furniture, Biscuit, Masonry Wall), 0'  0 5/16", if(or(and(Behind Furniture, Biscuit), and(Behind Furniture, Masonry Wall), and(Biscuit, Masonry Wall)), 0'  0 31/128", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256")))))

 

#2 - IF/SUM method (typically better when many parameters are involved):

if(and(Behind Furniture, Biscuit, Masonry Wall), 0'  0 5/16", if(if(Behind Furniture, 1, 0) + if(Biscuit, 1, 0) + if(Masonry Wall, 1, 0) = 2, 0'  0 31/128", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256")))))

 

Just ask if you have any more questions or if you'd like me to elaborate!

Corey D.                                                                                                                  ADSK_Logo_EE_2013.png    AutoCAD 2014 User  Revit 2014 User
──────────────────────────────────────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate to further enhance these forums. Thank you!
Contributor
jmqrsq
Posts: 16
Registered: ‎10-31-2011
Message 4 of 10 (584 Views)

Re: if and conditional formula help

01-15-2013 08:49 AM in reply to: CADastrophe

Thanks! I figured one way to do it although I was sure there had to be an easier and shorter way to do it:

 

if(and(Behind Furniture, Biscuit, Masonry Wall), 0'  0 5/16", if(and(Behind Furniture, Biscuit), 0'  0 31/128", if(and(Behind Furniture, Masonry Wall), 0'  0 31/128", if(and(Biscuit, Masonry Wall), 0'  0 31/128", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256")))))))

 

I was wondering if you could combine a if or & and conditional statement or not. I tried to do a search on Google but really wasnt sure what this would be called to use for keywords in my search. =) I will try to decipher what is going on in the examples you suggested to simplify any future formulas I do like this one. Any further explanation would be welcomed by me and any other person who stumbles accross this post.

 

Cheers!

*Expert Elite*
CADastrophe
Posts: 3,286
Registered: ‎08-28-2009
Message 5 of 10 (573 Views)

Re: if and conditional formula help

01-15-2013 09:14 AM in reply to: CADastrophe

To elaborate a little:

 


CADastrophe wrote:

#1 - OR/AND method (typically better when fewer parameters are involved):

if(and(Behind Furniture, Biscuit, Masonry Wall), 0'  0 5/16", if(or(and(Behind Furniture, Biscuit), and(Behind Furniture, Masonry Wall), and(Biscuit, Masonry Wall)), 0'  0 31/128", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256")))))


if(

  or(    < this means that if ANY of the conditional statements below return TRUE, then this returns TRUE

     and(Behind Furniture, Biscuit),               < each of these conditional statements tests

     and(Behind Furniture, Masonry Wall),     every combination of the YES/NO Parameters

     and(Biscuit, Masonry Wall)                         and will return TRUE if two of them are YES.

     )

  , 0'  0 31/128",                             < This is the result return if the OR statement is TRUE

   ,[the remainder of your formula]  < otherwise, it resorts to the remainder of the formula.

 )

 


CADastrophe wrote:

#2 - IF/SUM method (typically better when many parameters are involved):

if(and(Behind Furniture, Biscuit, Masonry Wall), 0'  0 5/16", if(if(Behind Furniture, 1, 0) + if(Biscuit, 1, 0) + if(Masonry Wall, 1, 0) = 2, 0'  0 31/128", if(Behind Furniture, 0'  0 11/64", if(Biscuit, 0'  0 11/64", if(Masonry Wall, 0'  0 11/64", 0'  0 27/256")))))


if(

  if(Behind Furniture, 1, 0)   < each of these statements test each YES/NO Parameter and returns 1 for YES, 0 for NO.

  +

  if(Biscuit, 1, 0),

  +                         < These results, which will either be 1 or 0, are added together to form the first part of the conditional statement

  if(Masonry Wall, 1, 0),

  = 2

  , 0'  0 31/128",                             < This is the result return if the above statement is true, meaning that the sum of the IF's is 2

   ,[the remainder of your formula]  < otherwise, it resorts to the remainder of the formula.

 )

 

 

Hope this is clear enough!

Corey D.                                                                                                                  ADSK_Logo_EE_2013.png    AutoCAD 2014 User  Revit 2014 User
──────────────────────────────────────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate to further enhance these forums. Thank you!
Contributor
jmqrsq
Posts: 16
Registered: ‎10-31-2011
Message 6 of 10 (561 Views)

Re: if and conditional formula help

01-15-2013 09:42 AM in reply to: jmqrsq

so is it the SUM boolean convert yes to 1 and no to 0? I always thought Revit auto recognized yes's as 1's and no's as 0's. If I had to guess that is still true here and instead of comparing all the parameters to each other you basically were testing if each one was a yes or no, then adding them up and using that result as a determining factor for the end result. Am I basically right thinking it is that simple?

*Expert Elite*
CADastrophe
Posts: 3,286
Registered: ‎08-28-2009
Message 7 of 10 (554 Views)

Re: if and conditional formula help

01-15-2013 09:48 AM in reply to: jmqrsq

There is no actual SUM function in Revit. And no, Revit does not interpret 1 and 0 as TRUE and FALSE, hence the need for the first IF statement. Essentially, the multiple 1 or 0 tests create a conditional statement as per the example below.

 

 = if( 1 + 0 + 1 = 2, 1/32", 1/64")

Corey D.                                                                                                                  ADSK_Logo_EE_2013.png    AutoCAD 2014 User  Revit 2014 User
──────────────────────────────────────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate to further enhance these forums. Thank you!
Contributor
jmqrsq
Posts: 16
Registered: ‎10-31-2011
Message 8 of 10 (544 Views)

Re: if and conditional formula help

01-15-2013 10:22 AM in reply to: CADastrophe

let me see if I am understanding this right. Tell me if this is a accurate and a working formula:

 

 if (if (a,1,0) + if (b,1,0) + if (c,1,0) + if (d,1,0) = 2, 1", if (a,1,0) + if (b,1,0) + if (c,1,0) + if (d,1,0) = 3, 2", 3") 

 

a = 1 then the result is 3"

a = 2 then the result is 1"

a = 3 then the result is 2"

a > 3 then the result is 3"

 

 

 

*Expert Elite*
CADastrophe
Posts: 3,286
Registered: ‎08-28-2009
Message 9 of 10 (536 Views)

Re: if and conditional formula help

01-15-2013 11:11 AM in reply to: jmqrsq

jmqrsq wrote:

let me see if I am understanding this right. Tell me if this is a accurate and a working formula:

if (if (a,1,0) + if (b,1,0) + if (c,1,0) + if (d,1,0) = 2, 1", if (a,1,0) + if (b,1,0) + if (c,1,0) + if (d,1,0) = 3, 2", 3"))


 This formula will function (albeit with an additional parentheses at the end).

 


jmqrsq wrote:

 if (if (a,1,0) + if (b,1,0) + if (c,1,0) + if (d,1,0) = 2, 1", if (a,1,0) + if (b,1,0) + if (c,1,0) + if (d,1,0) = 3, 2", 3") 

 

a = 1 then the result is 3"

a = 2 then the result is 1"

a = 3 then the result is 2"

a > 3 then the result is 3"


Not quite. Your "a" is a simple Yes/No parameter, not a number, so it can only be YES or NO. Your formula will return the result 1" if exactly two of the parameters (a, b, c ,d) are set to YES. It will return 2" if exactly three of them are set to "YES", and 3" for all other results, (which would be none of them checked, only one of them checked, or all of them checked).

Corey D.                                                                                                                  ADSK_Logo_EE_2013.png    AutoCAD 2014 User  Revit 2014 User
──────────────────────────────────────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate to further enhance these forums. Thank you!
Contributor
jmqrsq
Posts: 16
Registered: ‎10-31-2011
Message 10 of 10 (525 Views)

Re: if and conditional formula help

01-15-2013 12:36 PM in reply to: CADastrophe

right right. I knew that. Bad choice of using a instead of "result = ...".

 

I think I have it down now. Again I appreciate your help and explanation.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.