Announcement

Collapse
No announcement yet.

Conditional IF statement

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Conditional IF statement

    So I have a visibility control issue in a titleblock that I can't work out the syntax for.

    I just want this to be a simple formula but the syntax is messing with my head.


    I have two conditions I want to be met for a yes/no paramater.

    Length and Height

    If Length = x and Height = y then "yes" else "no"


    This isn't what I have put in revit because I know this (above) doesn't work, but I have tried so many ways now its not Worth listing them all.
    I'm only just starting to mess around with conditionals to drive visibility and I can't get it to work....and I am sure its syntax related.
    Or maybe I am using the wrong conditional statement?

    Any help would be great.

    #2
    https://www.revitforum.org/tutorials...day-usage.html

    Using logical AND:
    IF ( AND (x = 1 , y = 2), <true>, <false>)
    Returns <true> if both x=1 and y=2, else <false>
    you can force a yes/no by using statements that are true or false: yes: 1<2 or no: 1>2

    in your case: if(and(length=1,height=2),1<2,1>2))
    Last edited by cellophane; April 24, 2017, 02:04 PM.
    Revit for newbies - A starting point for RFO


    chad
    BEER: Better, Efficient, Elegant, Repeatable.

    Comment


      #3
      ok this is where the syntax is doing my head in? What is 1 and 2, why am I doing less than 2 greater than 1? I think its that seperator in the middle thats messing me up... I will see if this works, but the problem is, I will have no idea why it worked ....
      Thanks for the response

      Comment


        #4
        Originally posted by Karalon10 View Post
        What is 1 and 2, why am I doing less than 2 greater than 1?
        1= an integer
        2 = an integer

        (when integers)

        1 is NEVER greater than 2
        2 is ALWAYS greater than 1

        so it follows:

        1>2 is another way of saying "false"
        2>1 is another way of saying "true"

        Since we cannot use "True" and/or "False" as (Text) values for TRUE/FALSE, we use their mathematical equivalents (above) in formulaic expressions.

        Comment


          #5
          ok it didn't want to work

          I have a set L and H for each of these visibility status above, so it SHOULD be easy just L=X H=Y show parametre else dont show.

          But...nope..
          The error says, roughly... Length is an incorrect parameter (not sure why it is saying that because I have L in there, not "length") Then says the parameters are case sensitive...but again I didnt use the value "length" I used the "L" parameter name
          Attached Files
          Last edited by Karalon10; April 24, 2017, 02:31 PM.

          Comment


            #6
            OK - scratch that. Bizarre revit behaviour, I had to close down the parameters, open it again and try again. It had remembered an earlier entry and was blocking me somehow.

            It has worked, it had one too many brackets at the end, but apart from that it's worked.

            Comment


              #7
              Originally posted by cellophane View Post
              https://www.revitforum.org/tutorials...day-usage.html



              you can force a yes/no by using statements that are true or false: yes: 1<2 or no: 1>2

              in your case: if(and(length=1,height=2),1<2,1>2))
              and(Length = x, Height = y) is the better way of writing it. Yes/no parameters have a built in if/else condition, where you do not need to specify the 'else'.
              Developer at Anguleris BIMsmith Marketplace.
              Previously at Sumex Design for ARCAT.com

              Comment


                #8
                Originally posted by Andrew K View Post
                and(Length = x, Height = y) is the better way of writing it. Yes/no parameters have a built in if/else condition, where you do not need to specify the 'else'.
                Yes I think it was the fact he also assigned 1 and 2 to height and length, so I was not seeing the connection...anyhow, I get it now, kind of...Thanks

                Comment


                  #9
                  I like to use 1=1 for "always true" and
                  1=2 for "always false"
                  At least to me, it's a little more obvious than doing the (admittedly not difficult) math of < and >
                  Dave Plumb
                  BWBR Architects; St Paul, MN

                  CADsplaining: When a BIM rookie tells you how you should have done something.

                  Comment

                  Related Topics

                  Collapse

                  Working...
                  X