Need to list all parameter type names

Need to list all parameter type names

frankloftus
Contributor Contributor
76 Views
2 Replies
Message 1 of 3

Need to list all parameter type names

frankloftus
Contributor
Contributor

I want to programmatically add family parameters to a family doc using this method:

 

FamilyManager.AddParameter(String, ForgeTypeId, ForgeTypeId, Boolean)

 

To create a parameter, you must input the parameter type. To create a text parameter you would use this:

 

SpecTypeId.String.Text

 

But let's say I want to give the user a drop-down menu so they can select which parameter type, similar to the Revit UI:

 

Screenshot 2025-09-17 125823.png

 

So, I need to list all parameter type names.

 

I can use this to get all parameter types:

 

param_types = SpecUtils.GetAllSpecs()

 

But how do I get their names?

 

Everything about ForgeTypeId is very confusing to me.

0 Likes
Accepted solutions (1)
77 Views
2 Replies
Replies (2)
Message 2 of 3

longt61
Advocate
Advocate
Accepted solution

You can consider ForgeTypeId is just a fancy Autodesk type wrapping predefined enumeration. A part of it defines unit, while other part defines parameter type (spec type), etc..
As for getting the name of a given SpecTypeId, you might want to take a look at the LabelUtils.GetLabelForSpec() method. 
Hope this helps.

Message 3 of 3

frankloftus
Contributor
Contributor

Thank you. That is exactly what I needed. I looked through SpecUtils and didn't find any way to get a spec name. I didn't even think to look at another separate util class. I feel that these util classes are not grouped logically with the objects they operate on (not very OOP). Here is the solution I arrived at:

 

from selection_form_module import selection_form
from Autodesk.Revit.DB import SpecTypeId, SpecUtils, LabelUtils

# Get all param types
param_types_dict = {LabelUtils.GetLabelForSpec(spec) : spec \
					for spec in SpecUtils.GetAllSpecs()}

# Get sorted list of all param_type_names
param_type_names = sorted(param_types_dict.keys())

# Create selection_form
form = selection_form(param_type_names, 'Choose Parameter Type', 'Select')

# Show form
form.ShowDialog()

# Get the selected param_type_name
selected_param_type_name = form.selected

# Get param_type with selected name
selected_param_type = param_types_dict[selected_param_type_name]

# Output param_type
return selected_param_type
0 Likes