This site is not sponsored or endorsed by, or affiliated with, Autodesk, Inc.

Wednesday, February 1, 2012

Formulas in Families: Setting Limits

From (what appears to be outdated blog / website) All Things Revit,
I stumbled across a tutorial on Formulas in Familes....this was appealing to me because of my want/ need to learn more control in my families.

So, After going thru the process, I've made a few changes (mostly because this tutorial was made in RAC2010 and I wanted to learn in RAC 2012! and to strip out basic directions you should know by now!) to what you see below....

....Using formulas and creating complex families is not for the
faint-of-heart. While it’s not rocket science, a bit of "left-brain" is
helpful. Those with some programming knowledge, or experience with
Excel-type formula syntax should find this fairly straight-forward.

About The Family Created In This Tutorial

The examples that follow are intended to demonstrate concept. They
only scratch the surface of what’s possible. The family that we’ll
create primarily consists of reference planes. Additionally we’ll add
some symbolic lines so that the family is visible when it’s loaded into a
project.

Objectives

The main objective of the following exercise is to add an upper limit
of 6’- 0” and a lower limit of 2’- 0” to a length dimension, and to and
demonstrate its behavior using both Type and Instance parameters. The
exercise is broken down into three parts:

Create the Family: In this first section you'll create the initial family version, and add the required parameters and formulas.

Load the family into the project: In this section you'll load the family into the project and flex it to test the limits.

Modify the family: In this final section you'll
modify the family to make it more bullet-proof, and then reload it int
the project for verification.

Create The Family

Start a new "Generic Model" family.

Save the new family as: Grid 1.rfa

Create four reference planes as shown with a 2'-0" offset each way.

Add the dimensions, and create the equality constraints as shown:

(Adding equality
constraints as shown above will will cause the model to flex
symmetrically around a center axis in both directions. - I prefer this in most of my families....)

Click on one of the 4’- 0” length dimensions and then from the Label drop-down in the Options Bar select <Add parameter...>.

In the Parameter Properties dialog box, enter all values and settings as shown below, then click OK.

Click on the remaining 4’- 0” length dimension and then from the Label drop-down in the Options Bar select Length_Calc.

(The dimensions should now look as follows. If not, go back and repeat the necessary steps.)

Open the Family Types dialog box:

(Notice the parameter Length_Calc has been added with its default value set to the dimension length from which it was created.)

Click on the Add... button to open the Parameter Properties dialog box.

Enter all values and settings as shown below, then click OK. Be sure all fields are exactly as shown!

(Notice the parameter Length has been added in the Family Types dialog box, with its default value set to 0’ 0”.)

Enter the formula for the Length_Calc parameter exactly as shown below:

This “if” statement sets the upper threshold, or “max” value only. It basically says, “If the Length parameter is less than 6’- 0”, then use it, otherwise force the value to the upper limit of 6’ 0”.”

(Notice the value field for the Length_Calc parameter = 0’ 0”, which is the same as the Length parameter.)

In order to add a lower threshold, we need to insert a nested “if” statement.

Modify the formula for the Length_Calc parameter exactly as shown below:

We have now added a lower threshold of 2’ 0” to the formula. The whole formula basically means, “If the Length parameter is less than 6’ 0”, then check if the Length parameter is greater than
2’ 0”, if so then use it, otherwise force the value to the lower limit of 2’ 0”. If the Length parameter is not less than 6’ 0”, force the value to the upper limit of 6’ 0”.”(Notice the value field for the Length_Calc parameter is now
2’ 0”, which is the lower limit set by the formula.) This is because the
Length parameter is 0’ 0”, which is below the lower limit.

Change the value for the Length parameter to 4’ 0”. The value of the Length_Calc parameter should now also be 4’ 0”.

Experiment by setting various values for the Length parameter that are above and below the upper and lower limits of Length_Calc, and observe the behavior of the Length_Calc value field.

Reset the Length value to 4’ 0” and click OK.

Place and lock symbolic lines to the four outer reference planes as shown:|

Trim the four symbolic lines to form a closed box.

Save the Family

Load The Family Into a Project

Start a new project and open the "Level 1" floor plan view if not already there.

Switch back to the family Grid 1.rfa. and load the family into the project:

Place the family anywhere in the model, and zoom in to make it easier to see.

Dimension two sides as shown:

Select the Grid 1 element, navigate to Properties dialog box to enter 1’ 0” in the Value field for the Length parameter, then click OK.

(Notice that the element scaled symmetrically around the origin, and
the two dimensions have been restricted to the 2’ 0” minimum, despite
entering 1’ 0” for the Length value.)

Do the same thing again, but this time enter 8’ 0” in the Value field for the Length parameter, then click OK

(Notice that the element scaled symmetrically around the origin, and
the two dimensions have been restricted to the 6’ 0” maximum, despite
entering 8’ 0” for the Length value.)

Conclusion

Using formulas in families provides a powerful means of creating
highly flexible and complex models. As stated in the beginning of this
tutorial, knowledge of programming or Excel-type formula syntax is
extremely helpful. If you’re not up on this, I would recommend further
reading before attempting to tackle a family with complex formulas.

So this just begins to give a small taste of what formulas can do for our families... MORE TO COME