Getting all parameter types, group types and categories

Hello,

I’m trying to get a script working where I’d need a list of all the parameter types, group types and categories. I know that a node exists for each of these indivudually. However, I don’t want to use a drop down menu, but a full list of all the different parameter options. I’ve tried making a custom node with a giant list which I connected to a couple of hundred nodes for each different category etc. This makes my script very slow and not very useable.

Is it possible to make a python script (I gave it a try to no avail as I’m not great at it) or is there a node somwhere which gives me this list?

Thanks in advance

What have you tried so far? It helps if you show what you have tried
What is your use case, why do you need every type?
Look into a FilteredElementCollector for Group Class and ParameterElement Class
For BuiltInCategories and BuiltInParameters you could get all values with System.Enum.GetValues(<builtin>) and retrieve using System.Enum.GetObject(<builtin>, value)

1 Like

I tried making a script with Python, but I didn’t get anywhere. I gave up on that, because I didn’t seem to be getting any results due to the error which I was getting and couldn’t resolve.

Right now I have made custom nodes which are displayed below:

These custom nodes work, but they’re too slow. So I want to make a script which does the same in Python, but doesn’t make my script take 10 minutes to run each time.

You’re going to need a few different strategies to get all items from Revit classes depending what they are.

Classes with attributes (ForgeTypeId)
These hold various types of information in default properties like SpecTypeId.Weight or UnitTypeId.Celsius which refer to ForgeTypeId values. Python has a handy built in function called vars() that can extract the available attributes and you will have to filter for .NET methods and python attributes which usually have an underscore in their name and a few standard python functions of the class such as string, int, boolean, etc. We can then use the eval() function to turn a string representation into an object and voilà instant everything!

Code
import clr

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import SpecTypeId

properties = sorted(
    [
        v
        for v in vars(SpecTypeId)
        if "_" not in v and v not in ["Boolean", "Int", "Reference", "String"]
    ]
)


def props(p):
    obj = eval("SpecTypeId." + p)
    return p, obj.TypeId, obj


OUT = map(props, properties)

Built In Enumerations (System.Enum)
Revit has lots of enumerations which are collections of attributes that refer to an integer, this can be specific to a class, usually returning 0, 1, 2 etc. or returning a Revit internal ElementId integer which are negative. The two most used Enums are BuiltInParameter and BuiltInCategory and when we use Enums such as BuiltInParameter.VIEWPORT_SHEET_NAME or BuiltInCategory.OST_Walls these are integers. This is very handy because we can use these to get for example a class of a Parameter or Category, doc.GetElement(<integer>) or filter using the ParameterFilterRuleFactory or other filters as part of a FilteredElementCollector with conversion by using ElementId(<integer>).

Code
import clr

from System import Enum

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import BuiltInParameter

OUT = sorted(zip(Enum.GetNames(BuiltInParameter), Enum.GetValues(BuiltInParameter)))

Revit Classes (Autodesk.Revit)
Finally we get to gathering Revit classes using the FilteredElementCollector. I will not go into too much details as there is plenty of information online such as Dynamo Forum, Dynamo Python Primer and if you really want to get into the nitty gritty check out Jeremy Tammik’s blog Retrieving Elements Using FilteredElementCollector. Jeremey’s code is usually in C# however you can convert to python using online tools which should get you 80% of the way there.

Code
import clr

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import FilteredElementCollector, Group

doc = DocumentManager.Instance.CurrentDBDocument

groups = FilteredElementCollector(doc).OfClass(Group).ToElements()


def grp_info(g):
    view = doc.GetElement(g.OwnerViewId).Title
    return g.Name, view, g


OUT = map(grp_info, groups)

Note: If what you are using has a unique name it is quite simple to turn the information into a dictionary so you can retrieve info with a string as key. (You can also do this with System.Enum.GetValue())
image

Code
import clr

from System import Enum

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import BuiltInCategory, ElementId

bic_dict = dict(zip(Enum.GetNames(BuiltInCategory), Enum.GetValues(BuiltInCategory)))

elemid = ElementId(bic_dict[IN[0]])

OUT = elemid, type(elemid), bic_dict
5 Likes

Hello,

Thank you very much for the extensive reply. I was able to use it up to a certain point. However, I think that I should’ve uploaded a picture with my question, because I’m looking for a list which gives me all of the encircled types and groups in the parameter properties:

Is it possible to get these, or not? I already have a script which gives me the categories

import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import*
clr.AddReference(‘RevitServices’)
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
cat = doc.Settings.Categories
OUT = cat , [x.Name for x in cat]

Yes It is possible to get these enumeration using Revit API.
check the snap for your reference.

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import BuiltInParameterGroup

# Get all ParameterGroups
all_groups = [group for group in dir(BuiltInParameterGroup) if isinstance(getattr(BuiltInParameterGroup, group), BuiltInParameterGroup)]
OUT = []
for group in all_groups:
    OUT.append(group)

You can look at it as old school (Enums) vs new school (ForgeTypeId), but firstly lets get to those drop downs - Type of Parameter is a SpecTypeId, Group parameter under is a BuiltInParameterGroup. Old school is a bit hacky, new school has LabelUtils, ParameterUtils and UnitUtils. Revit is moving to ForgeTypeId for a lot of properties so now is probably a good time to lean in. Too much code to drop here - see the attached dyn file


Get_All_Info_R24.dyn (12.0 KB)

7 Likes

I’m sorry, but apparently this script doesn’t work for Revit2023 anymore. I tried it in 2022 where it worked fine, but gives out an error in 2023

ParameterType Enums has been removed from 2023 >

[ObsoleteAttribute(“This enumeration is deprecated in Revit 2022 and may be removed in a future version of Revit. Please use the ForgeTypeId class instead. Use properties of the SpecTypeId class and its nested classes to replace uses of specific values of this enumeration.”)]
public enum ParameterType

1 Like

Yes, I was working in Revit 2021 so that can happen.

In Revit 2024, I found that the “new school” method (ForgeTypeId) was missing about 10 spec types, including Fill Pattern, Image, Integer, Load Classification, Material, Multiline Text, Number of Poles, Text, URL and Yes/No.
I changed UnitUtils for SpecUtils and modified the Specs (ForgeTypeId) script:

import clr

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import SpecUtils, LabelUtils

def label(ftid):
    return LabelUtils.GetLabelForSpec(ftid), ftid.TypeId, ftid

OUT = sorted(map(label, SpecUtils.GetAllSpecs()))

I referenced this post by @GavinCrump : Replace Family Parameters with shared parameters - #15 by GavinCrump

2 Likes