Page 1 of 2 12 LastLast
Results 1 to 10 of 16
Like Tree4Likes

Thread: Nested Conditional statement

  1. #1
    Senior Member
    Join Date
    December 16, 2010
    Posts
    626
    Current Local Time
    09:33 AM

    Nested Conditional statement

    Hi again,

    Trying to figure out why this statement wont work
    (surely a syntax problem)

    If someone can correct this for me I would appreciate it

    I am trying to get this formula to say if the angle is greater than 22.5, then report 45. If the angle is less than 67.5 report 45, else report 90. (if true report 45, if false report 90)

    IF ( Angle > 22.5 , 45 , 90 , IF ( Angle < 67.5 , 45 , 90 ) )



    Revit is giving me an error saying it needs a value if its false but Ive given both replacement values so Im not sure whats going on.
    Do I perhaps need to use an IF/AND conditional instead of a nested conditional?
    Last edited by Karalon10; July 14th, 2017 at 10:52 AM.

  2. #2
    Senior Member
    Join Date
    December 16, 2010
    Posts
    626
    Current Local Time
    09:33 AM
    Actually think I just answered my own question - this formula works

    if(and(Angle > 22.5, Angle < 67.5), 45, 90)

  3. #3
    Senior Member
    Join Date
    December 16, 2010
    Posts
    626
    Current Local Time
    09:33 AM
    Now trying to complicate things by going one step further but having trouble with the OR conditional -

    if(and(or(Angle > 22.5░, Angle < 35░, Angle = 30░), or(Angle > 35░, Angle < 67.5░ , Angle = 45░), or(Angle < 67.5░ , Angle = 45░), or(Angle > 67.5░, Angle < 90░ , Angle = 90░ )))


    IF angle is greater than 22.5 AND less than 35 then angle = 30
    OR
    IF angle is greater than 35 AND less than 67.5 then angle = 45
    OR
    IF angle is greater than 67.5 AND less than 90 then angle = 90


    Its telling me Im missing the true false conditions, but to me they are implicated in the or statement...how do I get this formula syntax correct?

    I also tried these other 2 formulas neither of which have worked.

    if(and(or(Angle > 1░, Angle = 30░), or(Angle > 35░, Angle = 45░), or(Angle > 67.5░ , Angle = 90░)))

    if(and(or(Angle > 1░, 30░, 1), or(Angle > 35░, 45░, 90), or(Angle > 67.5░ , 90░,45)))
    Last edited by Karalon10; July 14th, 2017 at 11:45 AM.

  4. #4
    Senior Member
    Join Date
    December 16, 2010
    Posts
    626
    Current Local Time
    09:33 AM
    if(and(or(Length A > Length B, Length A = Length B), or(Length A > Length C, Length A = Length C))

    This is the "example" given that is supposed to work, and I see no "false" value here. Just if this condition is met, then one result OR the other - there is no such thing as a false result as it has to be one of the or statements....

  5. #5
    Forum Addict elton williams's Avatar
    Join Date
    December 7, 2010
    Location
    Gold Coast
    Posts
    2,005
    Current Local Time
    09:33 AM
    Quote Originally Posted by Karalon10 View Post
    if(and(or(Length A > Length B, Length A = Length B), or(Length A > Length C, Length A = Length C))

    This is the "example" given that is supposed to work, and I see no "false" value here. Just if this condition is met, then one result OR the other - there is no such thing as a false result as it has to be one of the or statements....
    I havent deciphered your formula but i can see 4 ( and only 3 )...

  6. #6
    Member chris.macko's Avatar
    Join Date
    April 12, 2011
    Location
    Chicago, IL
    Posts
    400
    Current Local Time
    06:33 PM
    This statement will work:
    if(and(Angle > 22.5░, Angle < 35░), 30░, if(and(Angle > 35░, Angle < 67.5░), 45░, if(and(Angle > 67.5░, Angle < 90░), 90░, 0░)))

    You need to provide the result if none of those conditions are true, I just used 0 in this case. The and/or route might be a little more complicated, but for starters your syntax is reversed. You'd need to have or(case 1, case2, case3), with each case being and(condition 1, condition2)
    Boolean operators return true/false statements, so you'd still need to translate that to an angle at some point. if you have notepad ++ it helps in organizing these nested formulas.
    Karalon10 likes this.

  7. #7
    Member chris.macko's Avatar
    Join Date
    April 12, 2011
    Location
    Chicago, IL
    Posts
    400
    Current Local Time
    06:33 PM
    Quote Originally Posted by Karalon10 View Post
    if(and(or(Length A > Length B, Length A = Length B), or(Length A > Length C, Length A = Length C))

    This is the "example" given that is supposed to work, and I see no "false" value here. Just if this condition is met, then one result OR the other - there is no such thing as a false result as it has to be one of the or statements....
    The only way that works is if it's a binary condition (yes/no parameter). In that case the if statement is also implied so you'd just start with the and(...
    If you want to convert a binary output to a different type of parameter, you need the if statement and a result if true, result if false.
    Karalon10 likes this.

  8. #8
    Senior Member
    Join Date
    December 16, 2010
    Posts
    626
    Current Local Time
    09:33 AM
    Thanks Chris, your formula has indeed worked, and thanks for explaining why mine wasn't working as intended.

    I was starting to try out seperating each statement (I think in my 3rd formula there) but I hadn't worked out to provide the true result after the end of each one, and only one false result at the end of the string....
    Last edited by Karalon10; July 14th, 2017 at 12:15 PM.

  9. #9
    Senior Member
    Join Date
    December 16, 2010
    Posts
    626
    Current Local Time
    09:33 AM
    I'm actually using it to report a value in a Schedule.
    I can not report the "Angle" of my piping elbow, and also my piping elbows come in either 30 degree, 45, or 90 degree shapes so even if my drawing is not quite at 45 degrees then it will force that angle to be output in my list without actually changing the "Angle" parameter

    I have used a shared parameter as intermediary - and my shared parameter uses the formula
    if(and(Angle > 22.5░, Angle < 35░), 30░, if(and(Angle > 35░, Angle < 67.5░), 45░, if(and(Angle > 67.5░, Angle < 90░), 90░, 0░)))

    The "Angle (by default)" parameter that is supplied in the elbow family for piping is a non-reportable paramater, so I had to find a work-around and as I mentioned, in addition I want to force the angles to actual fabricated values
    Attached Thumbnails Attached Thumbnails Nested Conditional statement-aa.png  

  10. #10
    Member duende123's Avatar
    Join Date
    November 20, 2015
    Posts
    118
    Current Local Time
    07:33 PM
    Quote Originally Posted by Karalon10 View Post

    if(and(or(Angle > 22.5░, Angle < 35░, Angle = 30░), or(Angle > 35░, Angle < 67.5░ , Angle = 45░), or(Angle < 67.5░ , Angle = 45░), or(Angle > 67.5░, Angle < 90░ , Angle = 90░ )))
    First.

    You can not modify the value of a parameter using the parameter itself in the formula that modifies its value
    So we are going to have 2 different parameters.
    Angle (real value)
    ANGLE (fixed value)
    To the latter we assign the formula:

    if(Angle < 22.5░, 90░, if( Angle < 35░, 30░,if(Angle < 67.5░ , 45░, 90░ )))


    IF angle is less than 22.5░: ANGLE = 90░
    else
    IF angle is less than 35░: ANGLE = 30░
    else
    IF angle is less than 67.5 : ANGLE = 45░
    else
    ANGLE = 90░

Page 1 of 2 12 LastLast

Similar Threads

  1. Conditional IF statement
    By Karalon10 in forum Architecture and General Revit Questions
    Replies: 8
    Last Post: April 24th, 2017, 03:22 PM
  2. Yes/No Parameter in Conditional Statement
    By keithwales in forum Architecture and General Revit Questions
    Replies: 3
    Last Post: September 16th, 2014, 05:00 PM
  3. Conditional Statement question
    By BLothian in forum Architecture - Family Creation
    Replies: 15
    Last Post: May 15th, 2014, 03:34 PM
  4. Visibility Yes/No Conditional Statement
    By Lisa in forum Architecture - Family Creation
    Replies: 9
    Last Post: February 11th, 2014, 12:29 AM
  5. Conditional Statement Help
    By Kent in forum Architecture - Family Creation
    Replies: 4
    Last Post: February 12th, 2012, 10:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •