Xrev API Tools: Increase Productivity!



Wednesday, April 12, 2006

Nested Arrays & Formulas

I have recently updated my tutorial for nested arrays and formulas which was getting quite old. The tutorial is available here: Nested Families & Arrays

Just in summarisation though, best practices when creating parametric arrays:

1. Always use nested families for elements that are to be arrayed

2. Always constrain the two defining elements of the array in all 3 axis. (defining elements are either the first and second or first and last depending on which option you've selected when creating your array)

3. Always constrain your arrayed elements by dimensioning to their origins. (their origin is the intersection of the three "defines origin" reference planes - THIS SHOULD BE LOCATED AT A LOGICAL POINT THAT YOU WANT TO CONSTRAIN TO, TO AVOID EXCESSIVE DIMENSIONS AND PARAMETERS)

Hopefully this quick cheat sheet can be used to diagnose issues with malfunctioning arrays.


Anonymous said...

mcould you email me a pdf copy of your Nested Arrays and Formula tutorial posted at RevitCity
It's hard to print out so that it is readable
my e-mail is coreed@hdo.com

Thanx Alot

Chris said...

Coreed, use this link to the PDF:


John said...

Mr Spot,
I tried doing the array Tutorial and was able to get all the way to step 112. The error I recieved improper use of boolean expression.
I can not get passed this. Everything up to this point seems to work fine. Any help would be appreciated.


Anonymous said...

Just thought figured it out. Always helps when you read and follow instructions.
Great tutorial.


Chris said...

Apologies John,

Another post I didn't notice... Email me if you still need help with this.


Christopher said...

Do you know the best way to make conditional clauses in the family such that is an obeject is greater than so many fett that it has 'X' of divisions?

Chris said...


That really isn't conditional. Conditional statements that make use of IF, AND & OR.

In your case technically you wouldn't have to use a conditional statement but I might include one to avoid an error message in your array if for instance the formula ever equalled 1 and thus Revit couldn't create the array.

For instance:

No of Divisions = IF( Width / Spacing < 2, 2, Width / Spacing)

Hope this helps.

Kevin said...


Thanks for the tutorial. I am trying to learn Revit on my own and am struggling with the proper formulas to use.

If we were to modify your louvre tutorial with the nested families and arrays, how would I change the No of Louvres formula to yield a quantity of louvres with defined free air value? In other words, I want to be able to specify the distance between the louvres (and be able to change this at any time) and have Revit calculate the quantity based on this distance and the vertical span.

Any help is appreciated.


Chris said...

Hi Kevin,

That's easily achieved, the only difference is you are applying a formula to the number of louvres and not the height. The formula for this would include something like height - (2xframe width) / (free air + louvre height).

jfonline said...

You all seem to know what you are talking about. I am curious what the best way is to create 2D (horizontal (1D) & vertical) and 3D (horizontal (1D), vertical (2D) and depth) arrays in Revit? Almost all examples of arrays in revit seem to be in only one direction.

I created a family called BOX and made it's parameters shared. I then created another family called BOXES and also made its parameters shared (though probably not necessary), and created a parameter in it for the Family/Type as well as two parameters to control the number of boxes horizontally and vertically.

I inserted BOX into BOXES and created a horizontal array just fine. I was able change able to change NUM_BOXES_HORIZ parametrically and have the array respond as expected. However, I then tried to group these and do another array vertically, with the number being controlled parametrically by NUM_BOXES_VERT. However, when I do this I can't seem to get the spacing to work properly vertically. If I switch and first array vertically and then horizontally, then the horizontal spacing gets fouled up, particulary when I start changing the BOX Type to be used. Am I just not properly constraining/anchoring the first box and the subsequent arrays, and if so, how do I? How can I align the 2nd and subsequent boxes so they are constrained/anchored to the previous box, regardless of it's size horizontally or vertically (and ultimately in depth as well?

I am now thinking perhaps the grouping process iself is the issue. Perhaps I should leave BOXES with just the horizontally arrayed elements and rename it BOXES_HORIZ or BOXES_1D and then create another family BOXES_VERT or BOXES_2D in which I would embed BOXES_HORIZ, I then might better control the behavior. It seems this should work, but also seems more complicated then necessary, especially if I then also wanted to do a 3D array and parametrically controlling the number of boxes deep, resulting in three layers of nested families:


Can anyone either acknowledge that this can work and/or ideally describe a simpler way to achieve my goal?

Thanks in advance,


Chris said...

Hi John,

Yes what you propose with the nesting will work. For each array that you want the base element to be parametric it requires nesting. If the box didn't change size then technically you can get away without nesting, you require the nesting step in order to have an origin for each controlling element in the array to constrain. That is, the first and last or first and second.