Get a list of ParameterGroups in R2025 API

Extraneous
Advisor
Advisor

Get a list of ParameterGroups in R2025 API

Extraneous
Advisor
Advisor

I need to get a list BuiltInParameterGroups to show these in a dialog window.

In the previous Revit API versions I used this:

List<BuiltInParameterGroup> groups = 
  Enum.GetValues(typeof(BuiltInParameterGroup)).Cast<BuiltInParameterGroup>().ToList();

How to do the same in Revit API 2025? GroupTypeId isn't Enum and I don't see how to get all possible values.

Alexander Zuev
In BIM we trust
Facebook | Linkedin | Telegram

0 Likes
Reply
Accepted solutions (1)
1,129 Views
6 Replies
Replies (6)

jeremy_tammik
Autodesk
Autodesk

You can use .NET Reflection to iterate over all the members of the GroupTypeId class:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

Mohamed_Arshad
Advisor
Advisor

Привет @Extraneous 

 

     As @jeremy_tammik  told, We use typeof keyword from Reflection to extract the property information. Kindly check the below sample code snippet for reference.

 

Reference Code:

 

 

 

 ///Get all Parameter Group Value in List
            List<PropertyInfo> propertiesInfo = typeof(GroupTypeId).GetProperties().ToList();

            Dictionary<ForgeTypeId, string> builtInParameterNames = new Dictionary<ForgeTypeId, string>();

            ///To Get all BuiltInParameter Group Names
            foreach (PropertyInfo property in propertiesInfo)
            {
                builtInParameterNames.Add(property.GetValue(property)as ForgeTypeId, property.Name);
            }

 

 

 

Спасибо 🙂 Hope this Helps 🙂

Thanks & Regards,
Mohamed Arshad K

Mohamed_Arshad
Advisor
Advisor

Привет @Extraneous 

 

   As @jeremy_tammik  told we can use the typeof from Reflection namespace. Kindly check the below code snippet for reference.

 

Reference Code:

 

 ///Get all Parameter Group Value in List
            List<PropertyInfo> propertiesInfo = typeof(GroupTypeId).GetProperties().ToList();

            Dictionary<ForgeTypeId, string> builtInParameterNames = new Dictionary<ForgeTypeId, string>();

            ///To Get all BuiltInParameter Group Names
            foreach (PropertyInfo property in propertiesInfo)
            {
                builtInParameterNames.Add(property.GetValue(property)as ForgeTypeId, property.Name);
            }

 

 

Hope this Helps 🙂

Thanks & Regards,
Mohamed Arshad K
0 Likes

eN27
Contributor
Contributor
Accepted solution

Reflection is not needed, since Revit 2022 there is a static method that returns all available GroupTypeId Members :


IList<ForgeTypeId> ParameterUtils.GetAllBuiltInGroups() 

There is a lot of static methods in the API that facilitate working with ForgeTypeId and the best way to discover them is through RDBE:

forum.gif

 



 

Mohamed_Arshad
Advisor
Advisor

HI @Extraneous  @eN27 @jeremy_tammik 

   @eN27 Thank you for the Suggestion, I make a summary of complete Query Thread. To extract the List of ForgeTypeId Class from GroupTypeId Class .

 

Suggestion-01 
@jeremy_tammik and me 
suggested to use System.Reflection Namespace | Microsoft Learn  from .NET. Kindly refer the below code snippet for additional reference.

 

Suggestion-01 Sample Code Snippet

///Get all Parameter Group Value in List
            List<PropertyInfo> propertiesInfo = typeof(GroupTypeId).GetProperties().ToList();

            Dictionary<ForgeTypeId, string> builtInParameterNames = new Dictionary<ForgeTypeId, string>();

            ///To Get all BuiltInParameter Group Names
            foreach (PropertyInfo property in propertiesInfo)
            {
                builtInParameterNames.Add(property.GetValue(property)as ForgeTypeId, property.Name);
            }

 

Suggestion-02

@eN27 suggested to use Revit API's In-Built GetAllBuiltInGroups Method. Kindly refer the below code snippet for additional reference.

 

Suggestion-02 Sample Code Snippet

///Get all Parameter Group Value in List
            var groupIds= ParameterUtils.GetAllBuiltInGroups();

            Dictionary<ForgeTypeId, string> builtInParameterNames = new Dictionary<ForgeTypeId, string>();

            ///To Get all BuiltInParameter Group Names
            foreach (ForgeTypeId groupId in groupIds)
            {
                builtInParameterNames.Add(groupId, LabelUtils.GetLabelForGroup(groupId));
            }

 

Hope this Helps 🙂

 

Thanks & Regards,
Mohamed Arshad K

Extraneous
Advisor
Advisor

Thank you @eN27 , it's exactly what I need.

Unfortunately Static methods aren't so usable because you won't find it if you didn't know about it already. I think API is heading somewhere in the wrong direction with this "forge id" idea. It seem even Jeremy forgot about this ParameterUtils and recommended to use Reflection. Bruh...

Alexander Zuev
In BIM we trust
Facebook | Linkedin | Telegram