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.