tm let revit do your work: using formulae to make advanced families michael vagg bornhorst + ward

20
TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Upload: piers-ball

Post on 22-Dec-2015

215 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

TM

Let Revit Do Your Work: Using Formulae To Make Advanced

Families

Michael Vagg

Bornhorst + Ward

Page 2: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Parameter Data TypesArithmetic Functions

Example 1 – Shear Stud

Conditional StatementsRoundingTrigonometry

Example 2 – Bracing Wall

Controlling Visibility

Example 3 – Reinforcement

INTRODUCTION

Page 3: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Selecting the correct parameter type early can save a lot of frustration while you’re working on your formulae. Before creating your parameters that will be formula driven, think carefully about the units involved.

This is one of the most frustratingerrors while building families:

If you do come across this error, notethat you cannot change the data type after the parameter is created. To change it, copy your formula to the clipboard, delete the current parameter, and recreate a new one of the correct data type.

You can review the Units for the various types by using the “Project Units” tool on the “Manage” tab.

PARAMETER DATA TYPES

Page 4: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Most data types are self-explanatory. Following are descriptions of those that we’ll be using that may be a little obscure.

NON-NUMERIC TYPESText - Simple text strings

- Can be used as the result of a conditional statement, but not as the test condition (we’ll cover this a little later)

Yes/No - Used to evaluate a condition, and returns either Yes or No.

- The conditional statement is implied, as are the return values

NUMERIC TYPESInteger - Unitless whole numberNumber - Unitless real (decimal) number

PARAMETER DATA TYPES (Cont…)

Page 5: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Description Operator SyntaxAddition + Length + WidthSubtraction - Length - WidthMultiplication * Length * 2Division / Length / 2

Square Root sqrt sqrt(9)Exponentiation ^ x ^ yLogarithm log log(100)Exponential Function exp exp(2)Absolute Value abs abs(-25)

Revit adheres to the Order of Operation in formulae, so the order of precedence will be Parentheses, Exponentiation, Division/Multiplication, Addition/Subtraction

ARITHMETIC FUNCTIONS

Page 6: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Open “Example 1.rvt” in Revit Structure 2011

EXAMPLE 1 – SHEAR STUD

Page 7: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

At present, the shear stud is predominantly static, with only the Height varied by user input. We now want to change this so that the user can also input the stud diameter. In doing so, this will also vary the stud head diameter.

The relationship between the stud & head diameters is as follows:2 x √2.5(Stud Dia.²)

EXAMPLE 1 – SHEAR STUD (Cont…)

In Revit, this can be expressed in a formula as:2 * (sqrt(2.5 * (Stud Diameter ^ 2)))

Page 8: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Conditional statements allow family builders to determine actions based on the values of other parameters. These have the form:if (test condition, true result, false result)

If the test condition proves true, the conditional statement will return the value of the “true result”. Should it prove false, it will return the “false result”.

You can use the following Logical Operators to build you test condition:Description Operator SyntaxGreater Than > x > 10Less Than < x < 10Equal To = x = 10Both statements are true AND and(x > 10, y < 10)One of the statements are true OR or(x > 10, x = 10)None of the statements are true NOT not(x > 10, y < 10)

CONDITIONAL STATEMENTS

Page 9: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Notice that there is no “Greater than or equal to …” operator (or its “Lesser than” brother)? This is achievable simply by using Less Than “<“ in conjunction with the not( ). So “not(X < Y)” will effectively give you “X ≥ Y”

Also, Revit doesn’t have in-built math constants that many of you may be used to. One of the most used of these is PI (π). As this is an irrational number, there is no method to accurately depict this in a formula. You can create your own Number parameter to approximate its value, but keep the innaccuracy in mind.

A NOTE ON MISSING OPERATORS & CONSTANTS

Page 10: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Whilst we have achieved our goal of making the Shear Stud parametric, with a formula-driven head diameter, note that the head diameter value is still accessible for the user.

This is because we have an unconditional relationship between the 2 parameters, so altering either of the 2 will change the other in accordance with our formula.

At times this may be the desired result, but in this case, the shear stud size will always be expressed as the stud diameter, and the head will always be a function of that.

We can effectively lock this parameter off by encasing the formula in a conditional statement.if(Stud Diameter > 0 mm, 2 * (sqrt(2.5 * (Stud Diameter ^ 2))), 0 mm)Note that the value field has now been disabled?

EXAMPLE 1 – SHEAR STUD (Revisited)

Page 11: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

General rounding in accordance with standard math convention can be achieved using an Integer data type. So, any number up to, but not including .5 will round down, while numbers .5 and above will round up.

To force upward or downward rounding, use a formula in an Integer parameter to Add or Subtract (respectively) 0.49 to/from the original value. This new value will then be automatically rounded by the data type as above.

It is also possible to round to any increment that you need. Below is an example of rounding to a 50 increment.

ROUNDING

Page 12: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Description Operator SyntaxSine SIN sin(30)Cosine COS cos(60)Tangent TAN tan(45)

Arcsine ASIN asin(1)Arccosine ACOS acos(1)Arctangent ATAN atan(1)

Refresher:Sin q = B / CCos q = A / CTan q = B / A

TRIGONOMETERY FUNCTIONS

q

CB

A

Page 13: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Formulae aren’t limited to use in family parameters – you can apply them to calculated values in schedules as well

Open “Example 2.rvt” in Revit Structure 2011

EXAMPLE 2 – BRACING WALL

Page 14: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Excerpt from AS1684.2 – Table 8.18

EXAMPLE 2 – BRACING WALL (Cont…)

Page 15: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Formulae aren’t restricted to family parameters. They can be used in schedules as well. Often, particularly with system families, using calculated values in schedules is the only way to achieve the outcome that you’re after.

In this example, we have 2 main requirements. We need to make sure that the wall length and angle restrictions are adhered to. We also want to round the wall length to a 300mm increment.

We’ll start with the wall length.

EXAMPLE 2 – BRACING WALL (Cont…)

Page 16: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

To round to a specified increment, we need 2 parameters. This will allow us to divide the original value by our increment, and round to a whole number. We then multiply this whole number by our increment value to result in the rounded value.

The first parameter (“Length Rounding”) needs to a be an Integer type. In this case, we want to always round down to a multiple of 300.

EXAMPLE 2 – BRACING WALL (Cont…)

(Length / 300 mm) - 0.49

Our second parameter “Bracing Length” will then check that the wall length falls between the required values of 1800 to 2700, and if so, create the rounded value. In this case, if the wall length falls outside of these values, in cannot be used for bracing, so will have a bracing length of zero.

if(or(Length < Minimum Length, Length > Maximum Length), 0 mm, Length Rounding * 300 mm)

Page 17: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

We now need to check the angle of the wall. To do this, we’ll use the Calculated Wall Height & Length parameters with a trigonometry function.

To calculate this, the math equation would be:Tan q = Calculated Wall Height / Length orq = Tan-1 (Calculated Wall Height / Length)

EXAMPLE 2 – BRACING WALL (Cont…)

In Revit, we can express this as:atan(Calculated Wall Height / Length)

As we need to check that the angle is between an upper and lower limit, we’ll need a conditional statement, but in this case it will be implied, as we’re using a Yes/No parameter type.

not(or(atan(Calculated Wall Height / Length) < 30°, atan(Calculated Wall Height / Length) > 60°))

Page 18: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Visibility can be controlled using Yes/No parameters. These can be made to act based on users’ input, geometric constraints, or a combination of both.

EXAMPLE 3 – REINFORCEMENT

In Revit Structure 2011, open “Example 3.rvt”.

The family on the left is complete, and behaves in the manor that we are seeking. Notice that when you move the extent line above or below the end of the reinforcing bar, a line appears to “link” the bar to it’s extent line?

We’ll now add this behaviour to the family on the right…

CONTROLLING VISIBILITY

Page 19: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

We need two conditions to prove true for our extension line to be displayed.

First, we need to ensure that the user has indicated that they want the extent arrow display based on the value of the Yes/No parameter “Display Extent Line”.

The second condition is based on the geometry of the component. We need to check that the extent line is outside the limits of the bar.

EXAMPLE 3 – REINFORCEMENT (Cont…)

To achieve this, we’ll need the AND logical operator, as we need both cases to prove true in order for our conditional statement to be true.And( … , … )We’ll use the first argument to check that “Display Extent Line” is trueand(Display Extent Line, … )The calculate whether our geometry suitsand(Display Extent Line, Extent Location < Extremity – Bar Extension)

Page 20: TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward

Revit Technology Conference 2010

Michael Vagg

Questions