Sunday, January 27, 2008

+/- offset(s) for families

So have you ever wanted to give users the ability to offset and object either plus or minus a certain distance from a constant reference point. Like maybe you have a custom curtain panel family that you want the user to be able to plug in 1' 0" to offset the panel forward one foot from the curtain wall centerline, or you want them to be able to put -6" into the same field and have the panel move backwards 6" away from the centerline. Well, here is the code and instructions:

1.) Create two reference planes, depending on what is important in your family they might represent the front face, back face or centerline of the panel/object. (For our demonstration we'll assume that we're using the front face.) Name one reference plane, "forward offset", name the other "front of panel". Make sure the forward offset ref plane is forward of the front of your constant (in this case the ref plane that is in the curtain panel template named "front"). Make sure the "front of panel" ref plane is behind your constant.

2.) Now create a dimension from your constant to the "forward offset" ref plane. Select the dimension and make it a parameter called "Offset Forward". Next create a dimension from the "forward offset" ref plane to the "front of panel" ref plane. Make this dimension a parameter and call it "Offset Back".

3.) Go into the Family Types dialog box. Create a new parameter called "Offset" set it be a length type of parameter. You can leave it at its default of 0' 0" or change it to some value, positive or negative.

4.) In the formula fields of our other two paremters enter this information:

Offset Forward - = if(Offset > 0', Offset, 0')
Offset Back - = if(Offset < 0', abs(Offset), 0')

That should be it, with the addition of the two formulas the offset will automatically go forward or back based on the positive or negative value entered into the "Offset" parameter. As long as I didn't screw up the order of the dimension strings to reference planes it will work just fine.

6 comments:

Phyllis Robbins said...

This is an excellent solution. Once I tried this, it was one of those, "Duh, why did I not think of this?" moments.

As a "tip and technique," I might suggest creating your geometry before adding the reference planes. Normally, I flex and test before I create any geometry. In this case, because the formulas force reference planes to reside in the same location, it is very easy to create geometry aligned to the wrong plane.

Not, of course, that I would ever do that...

Robert said...

Thanks for the compliment. At the least I would reccomend creating the reference planes, creating the geometry, then creating the paremeters, as you're right, once you set the parameters with the formula's correctly you will always have at least one refernce plane on top of another. Using the tab key to cycle through possible selection/alignment options also proves quite handy in this case.

-R

subzerocul said...

nice trick, but it's already inside revit for curtain wall. if you select the panel itself, right click for properties, then edit the type, you will see the offset parameter. positive value move the panel in one direction, negative does it in the other direction.

Robert said...

Suzerocul,

I agree, however the offset parameter is not available when you create a custom panel in the family editor and load it into your project, it is only available for system parameters. Also, as I alluded to, this technique can easily be applied to a number of other obejcts or conditions.

Darken said...

Thank you for this elegant solution.

Erik said...

An oldy, but a goody. Glad a colleague brought this to my attention. Saves the little but of hair I have left...