Page 1 of 30 1234511 ... LastLast
Results 1 to 10 of 292
Like Tree95Likes

Thread: Revit Formulas for "everyday" usage

  1. #1
    Administrator Munkholm's Avatar
    Join Date
    December 7, 2010
    Location
    Kingdom of Denmark
    Posts
    4,046
    Current Local Time
    12:31 PM

    Lightbulb Revit Formulas for "everyday" usage

    I´ve been building a lot of parametric content in Revit, and always enjoy the power of using formulas to drive and control things. So here´s a few examples that I´ve collected over time, and also some VERY recent additions (New rounding functions in Revit 2012).
    The basic operators (add, subtract, multiply, ect.) have been left out on purpose, but feel free to add more useful formulas, that you use in your families

    Exponentiation
    X raised to the power of Y = X ^ Y

    E raised to an x power
    E is a mathematical constant that is approximately equal to 2.7. It is an irrational number, but if we truncate it to 20 decimals it would be 2.7182818284590452353.
    Revit usage = exp(x)

    Circles with pi π
    Usage in Revit = pi()

    Circumference = pi() * (Radius * 2)
    Circumference = pi() * Diameter
    Circle Area = pi() * Radius ^ 2

    Square Root
    Fixed value = sqrt(999)
    Parameter = sqrt(Width)
    Formula= sqrt(Width + Height)

    Logarithm
    The logarithm of a number to a given base is the exponent to which the base must be raised in order to produce that number. For example, the logarithm of 1000 to base 10 is 3, because three factors of 10 must be multiplied to yield a thousand: 10 × 10 × 10 equals 1000
    Revit usage = log(1000)

    Force yes/no parameters to be checked or unchecked
    Force checked = 1 < 2
    Force unchecked = 1 > 2

    Conditional statements
    Conditional statement uses this structure:

    IF (<condition>, <result-if-true>, <result-if-false>)

    Supported Conditional Operators

    < Less than
    > Greater than
    = Equal
    / Divide
    AND Both statements are true
    OR One of the statements is true
    NOT Statement is false

    Conditional statements can contain numeric values, numeric parameter names, and Yes/No parameters.
    Currently, <= and >= are not implemented. To express such a comparison, you can use a logical NOT. For example, a<=b can be entered as NOT(a>b)

    Simple IF Statement
    IF (Length < 900, <true>, <false>)

    Formula That Returns Strings
    IF (Length < 900, “Opening too narrow”, “Opening OK”)

    Using logical AND
    IF ( AND (x = 1 , y = 2), <true>, <false>)
    Returns <true> if both x=1 and y=2, else <false>

    Using logical OR
    IF ( OR ( x = 1 , y = 2 ) , <true>, <false>)
    Returns <true> if either x=1 or y=2, else <false>

    Nested IF statements
    IF ( Length < 500 , 100 , IF ( Length < 750 , 200 , IF ( Length < 1000 , 300 , 400 ) ) )
    Returns 100 if Length<500, 200 if Length<750, 300 if Length<1000 and 400 if Length>1000

    IF with Yes/No condition
    Length > 40
    Returns checked box (<true>) if Lenght > 40

    NOT with Yes/No condition
    not(Viz)
    Returns checked box (<true>) if Yes/No parameter "Viz" is unchecked, and returns unchecked box (<false>) if Yes/No parameter "Viz" is checked.

    IF AND OR Returning the greatest of three values
    Say you have these 3 length parameters, and want a fourth parameter to return the greates value/lenght of the 3:

    Length A
    Length B
    Length C
    Return Length (Returns the greatest of the three length parameters)

    Return Length = if(and(or(Length A > Length B, Length A = Length B), or(Length A > Length C, Length A = Length C)), Length A, if(and(or(Length B > Length A, Length B = Length A), or(Length B > Length C, Length B = Length C)), Length B, if(and(or(Length C > Length A, Length C = Length A), or(Length C > Length B, Length C = Length B)), Length C, 0 mm)))

    Credit to: Joe Zhou for this formula!

    Another option is to use an extra "Calc" parameter, which is a bit more clumsy but also way easier and more manageable for us mortals.

    Calc = if(Length A > Length B, Length A, Length B)

    Return Length = if(Calc > Length C, Calc, Length C)

    And a third option:

    Return Length = if(A > D, if(A > C, if(A > B, A, B), if(B > C, B, C)), if(B > D, if(B > C, B, C), if(C > D, C, D)))

    Credit to: Ekkonap who posted this on May 23rd 2011.


    Trigonometry for right triangles:

    Known: a+b
    c = sqrt(a ^ 2 + b ^ 2)
    A = atan(a / b)
    B = atan(b / a)

    Known: a+c
    b = sqrt(c ^ 2 - a ^ 2)
    A = asin(a / c)
    B = acos(a / c)

    Known: b+c
    a = sqrt(c ^ 2 - b ^ 2)
    A = acos(b / c)
    B = asin(b / c)

    Known: c + A
    a = c * sin(A)
    b = c * cos(A)
    B = 90° - A

    Known: c + B
    a = c * cos(B)
    b = c * sin(B)
    A = 90° - B

    Known: a + B
    b = a * tan(B)
    c = a / cos(B)
    A = 90° - B

    Known: b + A
    a = b * tan(A)
    c = b / cos(A)
    B = 90° - A

    Known: a + A
    b = a / tan(A)
    c = a / sin(A)
    B = 90° - A

    Known: b + B
    a = b / tan(B)
    c = b / sin(B)
    A = 90° - B

    Range of Values

    Given the following parameters:

    user_value:
    min_value:
    max_value:
    actual_value: = if (user_value < min_value, min_value, if (user_value > max_value, max_value, user_value))

    Specify a range of valid entries, with the min_value and max_value parameters; then, use the actual value if it is within the range; otherwise, use your minimum or maximum values.

    Credits: Alfredo Medina, who posted this on March 23rd 2011

    Circular Segments.

    Here's how to calculate the Segment length, the Chord Length, the Angle etc. (Image should speak for itself)


    Sample file posted here



    Inconsistent Units

    Theres a seperate post explaining this behavior here:
    Revit - Inconsistent Units and how to neutralize them.

    Round Function In Formulas - New in Revit 2012
    Values in formulas can be now rounded up or down. For example, when riser height is calculated, one needs the function “round” to find the appropriate value.
    ROUND(x)
    The round function returns a number rounded nearest to a whole number. It doesn’t take into consideration rounding direction (round up or down). If the number is (for example) from 24.5 to 24.9, the function rounds it to 25. If it is from 23.1 to 23.4, the function rounds it to 23.
    Examples:
    round ( 23.4) = 23
    Round ( 23.5) = 24
    Round ( 23.6) = 24
    Round (-23.4) = -23
    Round (-23.5) = -23
    Round (-23.6) = -24
    Syntax
    The syntax for the round function is: round( number)
    number is the number to round.
    ROUNDDOWN(x)
    “x” is a unitless value that should return the smallest integral value less than or equal to x.
    For example:
    rounddown ( 23.0) = 23
    rounddown ( 23.5) = 23
    rounddown ( 23.9) = 23
    rounddown (-23.0) = -23
    rounddown (-23.5) = -24
    rounddown (-23.9) = -24
    The syntax for the rounddown function is: rounddown (number)
    number is the number to round down.
    ROUNDUP(x)
    “x” is a unitless value that should return the largest integral value greater than or equal to x.
    For example:
    roundup ( 23.0) = 23
    roundup ( 23.5) = 24
    roundup ( 23.9) = 24
    roundup (-23.0) = -23
    roundup (-23.5) = -23
    roundup (-23.9) = -23
    The syntax for the roundup function is: roundup (number)
    number is the number to round up.
    Note that when numbers such as 23.5 are rounded, they can result in either 23 or 24. To produce a stable result, for all the .5 cases, we round to the larger integer. That means that 23.5 is rounded to 24, while -23.5 to -23
    Last edited by Munkholm; May 3rd, 2012 at 06:50 AM. Reason: Had "roundup" and "rounddown" reversed :O)

  2. #2
    French Moderator jbenoit44's Avatar
    Join Date
    December 7, 2010
    Location
    Nantes, France
    Posts
    1,361
    Current Local Time
    01:31 PM
    great post Klaus! thanks

  3. #3
    Forum Co-Founder Alfredo Medina's Avatar
    Join Date
    December 7, 2010
    Location
    Orlando, FL, USA | info@planta1.com
    Posts
    2,257
    Current Local Time
    06:31 AM
    Geez! Munkholm and Aaron are going to be running for The Best Posts of the Month again!
    Excellent post! Very useful! We gotta love RFO!

  4. #4
    Moderator
    "OMG I killed Revit"
    dzatto's Avatar
    Join Date
    December 9, 2010
    Location
    Dallas, TX
    Posts
    5,037
    Current Local Time
    05:31 AM
    Speechless. At this rate, I'll never get a POTM nomination. lol

  5. #5
    Revit Maestro Scott Hopkins's Avatar
    Join Date
    December 14, 2010
    Location
    Santa Barbara, CA
    Posts
    62
    Current Local Time
    03:31 AM
    Wow! I hadn't yet seen a formula for "IF AND OR Returning the greatest of three values". This is a real tour do force!

  6. #6
    Moderator
    "RFO 2012 Spelling Bee Champion"
    Alex Cunningham's Avatar
    Join Date
    December 8, 2010
    Location
    Northern California
    Posts
    3,184
    Current Local Time
    03:31 AM
    I could of really used this list when I was making my gusset plates. Took me a week to figure it all out. Rep for you.

  7. #7
    Member Alex Page's Avatar
    Join Date
    December 14, 2010
    Location
    Wellington, New Zealand
    Posts
    266
    Current Local Time
    12:31 AM
    A little quirky timesaver as well, instead of:
    Parameter1 = Parameter2 *-1

    use

    Parameter1= -Parameter2

  8. #8
    Moderator gaby424's Avatar
    Join Date
    December 11, 2010
    Posts
    907
    Current Local Time
    01:31 PM
    And it's worh to mention that any poligon can be splited in triangles and that any triangle can be split in 2 right triangles. Eaven the right triangle can be splited in others 2 right triangles. Then you can use Munkholm formulas colection when study a geometry that is virtualy splited to a granular level of of right triangles.Of course triangles can be everywhere on a geometry, depends on the elements you choose to form your triangle.
    Last edited by gaby424; March 24th, 2011 at 08:49 AM.

  9. #9
    Administrator Munkholm's Avatar
    Join Date
    December 7, 2010
    Location
    Kingdom of Denmark
    Posts
    4,046
    Current Local Time
    12:31 PM
    Quote Originally Posted by Scott Hopkins View Post
    Wow! I hadn't yet seen a formula for "IF AND OR Returning the greatest of three values". This is a real tour do force!
    In all fairness, Joe Zhou came up with this genius formula!

    My initial take at it used an extra "Calc" parameter, which is a bit more clumsy but also way easier and more manageable for us mortals.

    Calc = if(Length A > Length B, Length A, Length B)

    Return Length = if(Calc > Length C, Calc, Length C)

  10. #10
    Forum Addict gdoherty0102's Avatar
    Join Date
    December 14, 2010
    Location
    United States
    Posts
    1,111
    Current Local Time
    05:31 AM
    Who would LOVE to see CONCATENATE from excel incorporated into Revit schedules???

Page 1 of 30 1234511 ... LastLast

LinkBacks (?)

  1. February 28th, 2012, 04:07 PM
  2. January 10th, 2012, 02:31 PM
  3. January 2nd, 2012, 07:57 PM
  4. December 2nd, 2011, 12:31 PM
  5. November 4th, 2011, 09:59 AM

Similar Threads

  1. Fórmulas de Revit para el "uso diario"
    By Munkholm in forum Foro Español
    Replies: 8
    Last Post: June 7th, 2011, 12:43 PM
  2. Slab slope discrepancy btw "Slope arrow" and "Define Slope"
    By jh75 in forum Structure - General Questions
    Replies: 3
    Last Post: May 6th, 2011, 09:39 PM
  3. Revit 2011 - "Black rendering" with Non-English Win XP
    By Munkholm in forum Tutorials, Tips & Tricks
    Replies: 0
    Last Post: January 10th, 2011, 09:15 AM
  4. Replies: 2
    Last Post: January 7th, 2011, 07:19 PM
  5. Replies: 2
    Last Post: January 7th, 2011, 07:19 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
  •