turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Close

Revit Architecture

- Autodesk Community
- >
- Revit
- >
- Revit Architecture
- >
- Parameter Length restricted to 6 inch intervals

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

762 Views, 4 Replies

12-14-2013 03:00 PM

Hello

does anyone know how to restrict a length parameter to 6 inch increments using a formula? Or another method? I have a simple frame I want to stretch dynamically in 6 inch intervals

thanks

Solved! Go to Solution.

Solved! by David_W._Koch. See the answer in context.

Create a length parameter that the end user can modify; make it instance-based (I assume you want variable lengths without having multiple types). Then create a separate parameter that takes the value of that length parameter and rounds the value to 6" increments and use that parameter as the one that drives the length of the family. (The second parameter will also have to be instance based, as you cannot mix type and instance parameters in a formula.)

There are three rounding functions: round, roundup and rounddown. Round goes to the nearest whole number (the Help does not explain how a fraction of exactly 1/2 is rounded, although the example shown in the Help and my experience indicates it rounds up), roundup rounds up to the next higher whole number and rounddown rounds down to the next lower whole number. Use the one that works for your purposes.

The rounding functions also only work on pure numbers, not numbers with units, so the user entered length will need to have the units stripped, and then added back after the rounding is done.

To get the rounding to be in 6" increments, you will have to divide the source number by 6, do the rounding and then multiply that result by 6. Stripping the units and adding the units back can be combined with the division and multiplication by 6. So your formula would look something like this:

**roundup(LengthUser / 0' 6") * 0' 6"**

where LengthUser is the instance-based property into which the user enters the length.

Since you are using the calculated value to drive a length constraint, you will also want to take precautions to avoid having it return a negative or zero value. One way this can be done is to use a third, instance-based parameter that actually drives the geometry. This parameter checks the value of the rounding parameter and, if it is greater than zero, passes through the value of the rounding parameter. If it is not greater than zero, it is set to some fixed value, such as 6", since that would be the minimum value, in 6" increments. The formula or this would look like this:

**if(LengthRounded > 0', LengthRounded, 0' 6")**

where LengthRounded is an instance-based property using the rounding formula shown above.

One downside of using formula driven parameters is that the grips that are available in the project for a family when an instance-based length parameter drives reference planes whose IsReference property is not set to Not a Reference are not present. The attached ZIP file contains a sample Revit project in 2014 format that contains an instance of a Generic family called RoundTo6InchesTest. This family has two model lines in it. The "Width" is driven by an instance parameter directly. The "Length" is driven by parameters similar to the ones described above, using the roundup option for rounding, and will only appear in 6" increments. The Width can be adjusted in the project via grips; the length cannot. (If anyone knows how to preserve the use of grips while driving the geometry with intermediate, formula-based parameters, please reply and explain how to do so.)

Solved! by David_W._Koch. See the answer in context.

Just after posting the previous reply, a means to make the "Length" grip stretchable in a project while maintaining the rounding on the family geometry occurred to me. I added another reference plane to the family, and added a labeled dimension to it for the LengthUser property. No actual geometry is tied to this reference plane, but by adding this the family has grips for the user to set the LengthUser parameter value graphically on screen, rather than by entering a value on the Properties palette.

If you want the user to enter a value rather than stretch a grip, then you would not need to add this additional reference plane and labeled dimension.

I also noticed that the dimensions that had been keeping the length line centered on the width line somehow got changed from being set to "EQ". I am attaching a ZIP file with the updated project file with the grip-stretchable length family in it as well as the family file.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-15-2013 09:01 AM in reply to:
hans409

Create a length parameter that the end user can modify; make it instance-based (I assume you want variable lengths without having multiple types). Then create a separate parameter that takes the value of that length parameter and rounds the value to 6" increments and use that parameter as the one that drives the length of the family. (The second parameter will also have to be instance based, as you cannot mix type and instance parameters in a formula.)

There are three rounding functions: round, roundup and rounddown. Round goes to the nearest whole number (the Help does not explain how a fraction of exactly 1/2 is rounded, although the example shown in the Help and my experience indicates it rounds up), roundup rounds up to the next higher whole number and rounddown rounds down to the next lower whole number. Use the one that works for your purposes.

The rounding functions also only work on pure numbers, not numbers with units, so the user entered length will need to have the units stripped, and then added back after the rounding is done.

To get the rounding to be in 6" increments, you will have to divide the source number by 6, do the rounding and then multiply that result by 6. Stripping the units and adding the units back can be combined with the division and multiplication by 6. So your formula would look something like this:

**roundup(LengthUser / 0' 6") * 0' 6"**

where LengthUser is the instance-based property into which the user enters the length.

Since you are using the calculated value to drive a length constraint, you will also want to take precautions to avoid having it return a negative or zero value. One way this can be done is to use a third, instance-based parameter that actually drives the geometry. This parameter checks the value of the rounding parameter and, if it is greater than zero, passes through the value of the rounding parameter. If it is not greater than zero, it is set to some fixed value, such as 6", since that would be the minimum value, in 6" increments. The formula or this would look like this:

**if(LengthRounded > 0', LengthRounded, 0' 6")**

where LengthRounded is an instance-based property using the rounding formula shown above.

One downside of using formula driven parameters is that the grips that are available in the project for a family when an instance-based length parameter drives reference planes whose IsReference property is not set to Not a Reference are not present. The attached ZIP file contains a sample Revit project in 2014 format that contains an instance of a Generic family called RoundTo6InchesTest. This family has two model lines in it. The "Width" is driven by an instance parameter directly. The "Length" is driven by parameters similar to the ones described above, using the roundup option for rounding, and will only appear in 6" increments. The Width can be adjusted in the project via grips; the length cannot. (If anyone knows how to preserve the use of grips while driving the geometry with intermediate, formula-based parameters, please reply and explain how to do so.)

David Koch

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-15-2013 09:17 AM in reply to:
David_W._Koch

Just after posting the previous reply, a means to make the "Length" grip stretchable in a project while maintaining the rounding on the family geometry occurred to me. I added another reference plane to the family, and added a labeled dimension to it for the LengthUser property. No actual geometry is tied to this reference plane, but by adding this the family has grips for the user to set the LengthUser parameter value graphically on screen, rather than by entering a value on the Properties palette.

If you want the user to enter a value rather than stretch a grip, then you would not need to add this additional reference plane and labeled dimension.

I also noticed that the dimensions that had been keeping the length line centered on the width line somehow got changed from being set to "EQ". I am attaching a ZIP file with the updated project file with the grip-stretchable length family in it as well as the family file.

David Koch

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-15-2013 03:12 PM in reply to:
David_W._Koch

Thanks so much. Your explaination was very educational. I got my picture frame working with your suggestions. I couldn't really follow the part about the if then statement, but I'm not sure I need it.

Thanks Again

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-17-2013 03:48 PM in reply to:
hans409

As long as the length value you enter does not get rounded to 0 or less, you would not need it. Just guarding against a user entering -2'-0" for the length value.

David Koch

Search This Board

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Announcements

The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.

- Privacy | Legal Notices & Trademarks | Report Noncompliance | Site map | © Copyright 2014 Autodesk Inc. All rights reserved

Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Please see the Autodesk Creative Commons FAQ for more information.