Posts

Revit Quirk: Mismatching Units and Hidden Parameters

Revit has a lot of quirks that need to be worked around, and that means finding those workarounds and taking advantage of them. There was an issue with units in previous versions of Revit (that has since been resolved – thankfully) that led to developing a useful trick: using hidden values to drive visible ones.

Before Revit 2014:

There were parameters that had issues displaying the correct way. For example, setting a piping flow rate to GPM with a formula would give an incorrect value using Air Flow units. Revit 2013 and earlier treat all flow formulas as Air Flow – it is hardwired in – even when dealing with piping, so using formulas can get tricky inside of families.

Project units set to GPM

Project units set to GPM

New parameter - Piping, Flow

New parameter – Piping, Flow

Formula uses CFM, Parameter's Units are in GPM

Formula uses CFM, Parameter’s Units are in GPM

As you can see in the above images, even while project units were set to GPM for flow the formula field only accepted values in CFM, the Air Flow project units. What’s more, it will only accept whole values: no fractions and no decimals. While the GPM field itself can be set to any value, locking it out with a formula is where the issue comes up.

Here’s where the workaround comes in.

If you use other parameters to store the value, and then only reference those parameters inside of a formula, it skips the conversion that normally takes place and displays the desired value. – in the correct units, to the correct unit accuracy. If the ‘storage’ parameters are made as Hidden Parameters, then they are not visible in the properties palette in the project.  Parameters that present value to the user remain visible while the ‘Storage Parameters’ do not (in this case, Flow Rate).  The great part about this is that whatever your project units, they will always be accurate. Even though the parameter that holds your “actual” GPM is hidden, changing project units to L/s will convert its value to L/s, etc.

To create a Hidden Parameter, all that needs to be done is to change a Shared Parameter’s “Visible” value to 0 inside of the shared parameter file prior to writing the parameter to the family.  A future post will focus on this little known feature and how INVIEW uses it extensively.

Revit 2014 and Beyond:

In current versions of Revit, the Formula units now match the units shown in the Value field.  However, the rounding increment shown in the formula field doesn’t always match what is shown in the Value field.  If a number gets rounded inside of a formula, its true value is lost: as far as Revit is concerned, the rounded value is the value that was initially input as soon as the Types dialogue is closed. For example, while still working in the same instance of the Types dialogue, a 1.5 that was rounded to 2 inside of a formula will read as “1.5” in the output, but once the dialogue is closed and reopened, it will read as a 2. Changing unit precision will not resolve this problem since the formula itself was “edited” to have the rounded value. This issue is most prominent with small values: fractions of a unit that when rounded, are lost.

A simple way to recreate this is to set Project Units to Feet and fractional inches. Unit precision does not matter in later versions of Revit: formula fields are very precise, regardless of project unit precision. If you were to create a Length parameter and set its Formula to a static value of .05”, it automatically converts to a fraction of 13/256”. Press okay to close to the types dialogue, convert project units to decimal inches, and reopen the types dialogue. You’ll see that the original value was lost and is now .051”. Values that small are not usually an issue – but it is something to keep in mind and is solid evidence to easily reproduce. Once a unit is rounded, its original value is lost in the family editor.

Storage Parameters:

Storing values inside of hidden parameters have quite a few uses, and prevent mistakes inside of families: values that would otherwise be unlocked and rely on the user to not change them can be locked completely, and unit accuracy can be guaranteed.

Let’s say there was a family that absolutely needed ¼” accuracy at all times. If you do not want Revit to ever round that value up or down, create two Hidden parameters: “Number” (Discipline: Common, Type: Number) and “Unit” (whatever your desired unit is. In this example, Discipline: Common, Type: Length). They will feed into a third parameter, “Visible Value” (same unit type as the “Unit” parameter. This parameter will be what users see). Set the “Number” parameter to be .25. Now use the “Unit” parameter, unlocked, to hold the value you want to set: if you want that ¼” accuracy, set the parameter to be 1”. In the formula field of the “Visible Value” parameter that users will be using, multiply the two hidden parameters together: in this example Number * Unit. Since “Number” and “Unit” are hidden they will not be seen inside of a project, but the Visible Value field will always be accurate – even if it’s rounded up or down by the project units, its value remains constant.

The usefulness does not end there: you can also use Storage Parameters to lock the values of parameters that always exist in a family, like Model and Description. If you had four separate types with unique values (such as a Part Number, Ordering Number, or SKU) you could use a hidden storage parameter to lock them out by Type instead of leaving the values open. The same goes for changing dimensions – multiple types with different Width, Height, and Depth could all be locked using a hidden value.

When I create a family, I usually name that Storage Parameter “z Type”, and there are very few families that I make without it: set “z Type” to be a different value for each of the types in a family, set all of the formulas to look for a specific z Type that informs them what their value is supposed to be. Voila: completely parametric family with locked values to prevent mistakes wherever they are needed. Correct “Cost” values for every type, security cameras that have the correct horizontal and vertical field of view, depending on lenses… The possibilities are endless.

Revit formula modeling for performance and scalability

There’s no right or wrong way to do anything in Revit, though some methods are more scalable. When writing formulas for families, it can prove advantageous to make it as human-readable as possible making edits faster and easier.

Through a process I call “funneling”, you can take multiple checkboxes and assign them an easily referenced value from an integer parameter. Imagine a heat pump available in three voltages (208/230/460V) and two frequencies (50/60 Hz) available with and without a heater or a humidifier. Each combination produces a different Rated Load Amps, 24 possible values in total. By this point, most will have resorted to using a type catalog, but this can easily be handled using instance checkboxes.

First, we create checkboxes for each available voltage and an integer parameter. The integer parameter should not be named “Voltage” since we’ll probably want a true Voltage parameter later, so I use “Voltage Selection”. Write a formula that looks at each checkbox and assigns a numerical value based on which one is selected.

Revit Integer Parameter Funneling

I prefer to go in ascending incremental order for legibility and I never use the “False” of the statement for a usable value. This ensures that none of the options are missed in the funnel and counting parenthesis is easy since it’s equal to how many options we have. The funnel parameter is the separation between input and output, allowing us to change our outputs without affecting inputs and vice versa. By doing this with the remaining options for frequency, humidifier, and heater, we can use Excel to concatenate our 24 possible outcomes with a simple “if(and(“ statement referencing each parameter to a value like a combination lock.

Revit Integer Parameter Funneling

Array out your combinations almost like you would for a type catalog and start a concatenate for just one row in another column. Lock the referenced cell holding the funnel parameter names in the columns and rows direction (with a “$” before each letter and number) so they don’t move at all. Lock the funnel parameters values in the column direction (with a “$” before the number only) so each formula fragment will reference the appropriate value for that combination when you drag the concatenate downwards, but not allow the cell with the reference parameter name to change at all. Then concatenate the formula fragments at the bottom and copy over into the cell next to it. Input a closing parenthesis in the cells the new concatenate references. This will count your parenthesis for you. Assign a false value for the formula and concatenate the three parts together:

  1. The concatenate of the true values
  2. The false value
  3. The concatenate of the closing parenthesis

Once created, the whole structure is scalable. The parameter names or values can be changed at any time and the formula will still work because the concatenate updates automatically. The structure can also be easily edited to create formulas for the rest of the family by adding or removing formula fragments (Rows) or referenced parameters (Columns) independent of each other. Multiple formulas can also be written at the same time if they reference the same parameters as seen at the end of the video. It would of course be a good idea to save the Excel Book wherever the family is saved if you ever want to come back and make changes later.

 

I hope this helps you create some powerful formulas! Feel free to leave me a comment below if you have any questions.