Tag: Revit Families

  • Revit Families 104 – Trigonometry for Right Triangles

    Revit Families 104 – Trigonometry for Right Triangles

    Prior to reading this post we recommend reading “Revit Families 103 – Formula Basics” to get the complete overview of all the basic operations allowed in Revit formulas.

    Many times when working with Revit Formula in family creation you will want to work with right triangles.  The following is meant as a handy reference for you to make working with right triangles a little easier.

     

    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

  • Revit Families 402 – Greater Than or Equal To

    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>)


    (more…)

  • Revit Families 102 – Revit Experts don’t Use Locks

    In May I published my picks for Best Revit Blogs on the Web.  Coming in at number 2 was The Revit Kid and Jeff’s Lock Noob Classic Thong.  I still try to read everything Jeff writes but I thought I might stir up a little controversy and make the argument that, contrary to what the thong says, a Revit expert is one who doesn’t use locks.

    I think that Jeff has it backwards.  In my experience the newcomer to Revit wants to lock everything.  I think the initial instinct is to not trust Revit and just lock things down.  Later when this user tries to change something they get a string of messages telling them constraints aren’t met and they end up getting frustrated and removing all the locks anyway.

    therevitkid-locknoobthong

    I’m sure Jeff would argue that the Revit Expert knows how to use locks properly.  I would agree that as you experiment with Revit you learn when to lock and when not to lock.  With Revit family creation that time is only as a last resort.

    So what to do instead of locking?

    1. Reference lines and planes:  Hosting and aligning geometry to reference lines and planes automatically creates a strong connection between them.  The link isn’t quite as strong as a lock, under some conditions it will detach.  But for most purposes it works just fine.  Align geometry to a reference plane and flex your model.  You’ll be surprised how often this works.  Carl Gibson has a great overview of the types of Reference lines.
    2. Parameters:  Instead of locking a dimension to a fixed dimension assign a parameter to it.  Using parameters gives you flexibility to easily change things later, and more importantly it lets the user of the family know what’s going on inside it without having to edit the family.  For example, create a a parameter called Table Thickness and give it the formula 0′ 2″.  This tells the user that the Table is 2″ thick and locks it from changing.  Note that locking a parameter with a formula locks it across all types in the family.

    Locking does have it’s place, but I always try to make a family work without locks first.

  • Revit Families 401 – Data Validation

    As I mentioned in a follow up comment to Revit Families 103 – Formula Basics, Revit still doesn’t allow you to do data validation on values or formulas in families or on table data.

    Still, you can build some functionality into your families to ensure that a value never exceeds a specified range or create warnings for the user of your family.

    Lets start with a simple example.  In the plan view below I am showing a basic table.

    Screen1

    Lets say in this example that we never want the table’s width to be greater than 1/2 the depth.  We have a few choices.

    1. Don’t do anything
    2. Display an error message for the user
    3. Default to another value

    (more…)

  • Revit Families 103 – Formula Basics

     

    Update: 4/12/11 for Revit 2012 and added more examples.

    I love formulas, they let you do some really fun things.  The formula I mentioned in my last post calculates the overall width of a family taking into account if the family has one or two loops toggled to be visible.  Formulas let you create a family that is truly flexible and has a lot of built in intelligence and a few safeguards.  They can also make using the family a lot easier to use by maintaining relationships between elements or calculating details about the family like area, volume, etc.

    I do some pretty advanced stuff with formulas, but we need to get the basics under our belt first.  Most of this post is from the Revit Help files.  To save you the trouble of looking it up, I’m putting it here.

    Keep in mind that Revit is aware of units.  So to avoid getting an inconsistent units error remember to divide and multiply when appropriate.
    For example, these are correct formula:

    (Length_A * Length_B) = Area_C
    (Length_A * Length_B)/1 = Length_C

    Basic opperators:

    + Add: 15′ + 0′  6″ + Length sin Sine: sin(75)
    Subtract: 1′ 2″ – Width cos Cosine: cos(75)
    * Multiply: Length * Width tan Tangent: tan(75)
    / Divide: Length / 8 asin Arcsine: asin(75)
    ^ Exponent: x^y, x raised to the y power acos Arccosine: acos(75)
    log Logarithm: log (100) atan Arctangent: atan(75)
    sqrt Square root: sqrt(64), square root of 64 = 8
    exp E raised to an x power: exp(2)
    abs Absolute Value: abs(-2), will return 2
    pi pi: pi() * (Radius ^ 2), the formula for Circumference

    Conditional Statements

    A conditional statement uses this structure:

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

    This means that the values entered for the parameter depend on whether the condition is satisfied (true) or not satisfied (false). If the condition is true, the software returns the true value. If the condition is false, it returns the false value.

    Supported Conditional Operators

    < Less Than
    > Greater Than
    = Equal to
    / Divide: Length / 8
    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).  For more information see “Revit Families 402 – Greater Than or Equal To

    Sample Conditional Statements

    Simple IF Statement
    IF (Length < 30′, 2′ 6″, 4′)

    Formula That Returns Strings
    IF (Length > 30′, “This thing is tall”, “This thing is short”)

    Using logical AND
    IF ( AND (x = 1 , y = 2), 8 , 3 )

    This will return <true> if both x=1 and y=2, else <false>

    Using logical OR
    IF ( OR ( A = 1 , B = 3 ) , 8 , 3 )

    This will return <true> if either A=1 or B=3, else <false>

    Nested IF statements
    IF ( Length < 10′ , 1′ , IF ( Length < 20′ , 2′ , IF ( Length < 30′ , 3′ , 4′ ) ) )

    Returns 1′-0″ if Length<10′-0″, 2′-0″ if Length<20′-0″, 3′-0″ if Length<30′-0″ and 4′-0″ if Length>30′-0″

    IF with Yes/No condition
    Length > 10
    (Note that both the condition and the results are implied.)

    Returns checked box <true> if Length > 10

    NOT with Yes/No condition
    not(myCheckbox)

    Returns checked box (<true>) of Yes/No parameter “myCheckbox” is unchecked, and it returns <false> if “myCheckbox” is checked.

    Rounding

    Prior to Revit 2012 the only way to round numbers was to pass a number through an integer parameter.  The integer parameter always rounds to the nearest whole number with the standard mathematical rounding rules of:

    Down -> for fractions of 0.0 to 0.49 and -0.5 to -0.99
    Up -> for fractions of 0.05 to 0.99 and -0.49 to 0.0

    As of Revit 2012 we now have three additional functions to use!!

    Note that “x” is unit-less

    Round(x)
    Rounds to the nearest whole number per the standard rules mentioned above.

    round (1.1) = 1
    round (1.5) = 2
    round (1.7) = 2

    round (-1.1) = 1
    round (-1.5) = 1
    round (-1.7) = 2

    Roundup(x)
    Rounds to the largest whole number greater than or equal to “x”.

    round (1.0) = 1
    round (1.5) = 2
    round (1.6) = 2

    round (-1.0) = 1
    round (-1.5) = 1
    round (-1.6) = 1

    Rounddown(x)
    Rounds to the smallest whole number less than or equal to “x”.

    round (1.0) = 1
    round (1.5) = 1
    round (1.6) = 1

    round (-1.0) = 1
    round (-1.5) = 2
    round (-1.6) = 2

    Some Extra Stuff

    • Revit allows you to use integers, decimals, fractional values, and parameter names in formulas.  You can enter dimensions in feet and inches just like you do in dimension strings.  Remember that parameter names are case sensitive.
    • You can enter a value in a formula essentially locking it across all types.  This is an alternative to locking the dimension in the model.
    • Instance and Type parameters can not be used in the same formula.
    • It’s a good idea to not name your parameters with any of the mathematical operators in this list.