TM Let Revit Do Your Work: Using Formulae To Make Advanced Families Michael Vagg Bornhorst + Ward
Revit Technology Conference 2010 Parameter Data Types Arithmetic Functions Example 1 – Shear Stud Conditional Statements Rounding Trigonometry Example 2 – Bracing Wall Controlling Visibility Example 3 – Reinforcement INTRODUCTION
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 frustrating errors while building families: If you do come across this error, note that 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
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 TYPES Text - 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 TYPES Integer - Unitless whole number Number - Unitless real (decimal) number PARAMETER DATA TYPES (Cont…)
Revit Technology Conference 2010 DescriptionOperatorSyntax Addition+Length + Width Subtraction-Length - Width Multiplication*Length * 2 Division/Length / 2 Square Rootsqrtsqrt(9) Exponentiation^x ^ y Logarithmloglog(100) Exponential Functionexpexp(2) Absolute Valueabsabs(-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
Revit Technology Conference 2010 Open “Example 1.rvt” in Revit Structure 2011 EXAMPLE 1 – SHEAR STUD
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)))
Revit Technology Conference Edit the family In the Project Browser, under Families > Generic Models, right click on Shear Stud (the family, not the type) & select edit. EXAMPLE 1 – SHEAR STUD (Cont…) 2.Go to the plan view Again in the Project Browser, open the Ref. Level view under Views > Floor Plans.
Revit Technology Conference Assign labels to dimensions Assign the Head Diameter label to the 50mm dimension, and the Stud Diameter label to the 12mm dimension. EXAMPLE 1 – SHEAR STUD (Cont…) 4.Add the formula Open the Family Types dialog, and add our formula to Head Diameter.
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: DescriptionOperatorSyntax Greater Than>x > 10 Less Than<x < 10 Equal To=x = 10 Both statements are trueANDand(x > 10, y < 10) One of the statements are trueORor(x > 10, x = 10) None of the statements are trueNOTnot(x > 10, y < 10) CONDITIONAL STATEMENTS
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
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)
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
Revit Technology Conference 2010 DescriptionOperatorSyntax SineSINsin(30) CosineCOScos(60) TangentTANtan(45) ArcsineASINasin(1) ArccosineACOSacos(1) ArctangentATANatan(1) Refresher: Sin = B / C Cos = A / C Tan = B / A TRIGONOMETERY FUNCTIONS C B A
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
Revit Technology Conference 2010 Excerpt from AS – Table 8.18 EXAMPLE 2 – BRACING WALL (Cont…)
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…)
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) 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 Maximum Length), 0 mm, Length Rounding * 300 mm)
Revit Technology Conference 2010 EXAMPLE 2 – BRACING WALL (Cont…) 1.Edit the schedule Right click on the schedule and select Edit, then unhide all columns. 2.Add the rounding formulae On the Fields tab of the Schedule Properties, select the Length Rounding parameter, and click Edit. Next, add the formula to the Bracing Length parameter in the same manner.
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 = Calculated Wall Height / Length or = 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) 60°))
Revit Technology Conference 2010 EXAMPLE 2 – BRACING WALL (Cont…) 3.Check the angle of the wall Add the parameter to check that the wall angle is between our required values. Now, as you move the extents & height of the wall, you’ll notice the bracing capacity will change in accordance with the rules that we have just defined.
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
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 true and(Display Extent Line, … ) The calculate whether our geometry suits and(Display Extent Line, Extent Location < Extremity – Bar Extension)
Revit Technology Conference 2010 EXAMPLE 3 (Cont…) 1.Edit the family Select the right-hand component and edit the family. Note the extension lines have their visibility linked to a parameter… 2.Add the formulae In the Family Type editor, enter the formulae that we’ve just developed, then reload the family into the project
Revit Technology Conference 2010 Michael Vagg Questions