0

My team is developing a plugin for Autodesk Revit. We would like to provide the user with a custom parameter (project or shared) that appears in the Properties panel of all (or most) structural elements, that lets the user select from one of a small set of pre-defined values. i.e. a parameter of type "enum". For the sake of example, pretend that we want to add a parameter whose values can be "Red", "Yellow", "Blue", and "Green", whose meaning is only relevant within the context of our plugin.

This is, to our surprise, not at all straightforward, to the point that I have not yet found a code example that demonstrates how to do it. I assume it's a rare use case in the Revit world.

One promising lead is the "Family Type" parameter type, but it is unclear how to use this to our ends. It's also possible, from a mention in another forum post, that a key schedule would help. If anyone can explain how these mechanisms could be used to this end, please provide any and all suggestions.

From blog posts, I gather that a text parameter will display, as a convenience, a pulldown containing all values for the parameter already existing in the model, but this does not completely solve our problem - we need the user to able to assign values without those values already existing in the model.

A lesser solution is to make the parameter an integer or text value, and have the user manually type the value when necessary. Less than ideal, in part because the user might type it incorrectly. We would like them to be able to simply select one of our pre-defined values from a pulldown.

Another lesser solution is a set of Yes/No parameters, one for each enum value. Poses a problem if the user selects more than one for a single element by accident.

Does anyone know how one creates such an "enum" pulldown parameter?

We will figure it out, but any help here would greatly expedite the research.

Jake
  • 2,852
  • 7
  • 32
  • 39

2 Answers2

0

After speaking with a Revit consultant, I've determined that there is no way to create a pulldown parameter with custom values in Revit. Instead, the solution is to create multiple Yes/No checkboxes, and give the checkboxes conditional logic that makes them mutually exclusive. This is known as an "if/then parameter". I haven't yet found code to set a parameter's conditional logic through the API, or had the opportunity to research further, but a comment on a forum implied that it is easy to do.

If anyone can post the code to do this, I'll mark that as the answer.

Jake
  • 2,852
  • 7
  • 32
  • 39
0

Have a look at 'schedule Keys'. You can populate the parameters with the api for the key schedule. This will give you the dropdown in the properties pallet. Then depending on which one is selected the other values will be set. I would recommend creating a schedule key in Revit and tinkering with it to get your head around what it is doing then you can create it with the api.

Bing
  • 149
  • 1
  • 5