Getting the values ​​of "Group parameter under"

Getting the values ​​of "Group parameter under"

2lenin-off
Enthusiast Enthusiast
764 Views
7 Replies
Message 1 of 8

Getting the values ​​of "Group parameter under"

2lenin-off
Enthusiast
Enthusiast

I'm working on a plugin that batch processes global settings. I am facing a problem: I can't get values ​​for "Group parameter under": Not all values ​​are included in this list.

What am I doing wrong?

Снимок экрана 2024-10-02 173452.png

        static public List<string> AddingGroupingOptionsToDictionary(Document _doc)
        {
            List<string> parameterGroupNames = new List<string>();

            FilteredElementCollector collector = new FilteredElementCollector(_doc)
                                         .WhereElementIsNotElementType();

            foreach (Element elem in collector)
            {
                foreach (Parameter param in elem.Parameters)
                {
                    BuiltInParameterGroup group = param.Definition.ParameterGroup;

                    string groupName = LabelUtils.GetLabelFor(group);
                    if (!parameterGroupNames.Contains(groupName))
                    {
                        parameterGroupNames.Add(groupName);
                    }
                }
            }

            return parameterGroupNames;
        }

 Thanks in advance for your reply!

0 Likes
Accepted solutions (1)
765 Views
7 Replies
Replies (7)
Message 2 of 8

sragan
Collaborator
Collaborator

I'm not sure offhand.  It looks like you are going through every parameter of every element in the file, and getting that parameters group.   It seems like there should be an easier way.  At any rate, it makes testing the code very difficult.   

 

When I compile, I get 3 warnings.   Maybe try using these newer methods? See the attached image.

0 Likes
Message 3 of 8

sragan
Collaborator
Collaborator

Try something like this;

For some reason, I got a lot of errors with parameters that don't seem to have group names, hence the "try-catch" statement.  (If you uncomment the "TaskDialog.Show " line in the catch statement, be prepared to hit escape a whole lot of times.)

List<string> parameterGroupNames = new List<string>();

            FilteredElementCollector collector = new FilteredElementCollector(doc)
                                         .WhereElementIsNotElementType();

            string grpnames = "";
            foreach (Element elem in collector)
            {
                foreach (Parameter param in elem.Parameters)
                {
                    
                    try
                    {
                    ForgeTypeId grpID = param.Definition.GetGroupTypeId();
                    string groupName = LabelUtils.GetLabelForGroup(grpID);
                    
                    //string groupName = LabelUtils.GetLabelFor(group);
                    if (!parameterGroupNames.Contains(groupName))
                    {
                        parameterGroupNames.Add(groupName);
                        grpnames = grpnames + groupName + "\r\n";
                    }
                    }
                    catch
                    {
                    	//TaskDialog.Show ("Error", "Cant get group name");
                    	
                    }
                }
            }

            
            //return parameterGroupNames;
            
            TaskDialog.Show ("Group Names", grpnames);
0 Likes
Message 4 of 8

2lenin-off
Enthusiast
Enthusiast

I hope there is a method that will accomplish this task without errors and much easier.

I get a lot of parameters that are not in the list.

0 Likes
Message 5 of 8

2lenin-off
Enthusiast
Enthusiast
Accepted solution

So, with all the options for forming the list, I either got extra elements, or some elements were missing.

As a result, I compiled a list of elements myself: I hope it will be useful to someone.

        static public List<BuiltInParameterGroup> CreateGroupParameterList()
        {
            List<BuiltInParameterGroup> groupParameters = new List<BuiltInParameterGroup>();

            groupParameters.Add(BuiltInParameterGroup.PG_ANALYTICAL_MODEL);
            groupParameters.Add(BuiltInParameterGroup.PG_VISIBILITY);
            groupParameters.Add(BuiltInParameterGroup.PG_SECONDARY_END);
            groupParameters.Add(BuiltInParameterGroup.PG_ANALYTICAL_ALIGNMENT);
            groupParameters.Add(BuiltInParameterGroup.PG_DIVISION_GEOMETRY);
            groupParameters.Add(BuiltInParameterGroup.PG_GRAPHICS);
            groupParameters.Add(BuiltInParameterGroup.PG_DATA);
            groupParameters.Add(BuiltInParameterGroup.PG_CONSTRAINTS);
            groupParameters.Add(BuiltInParameterGroup.PG_IDENTITY_DATA);
            groupParameters.Add(BuiltInParameterGroup.PG_MATERIALS);
            groupParameters.Add(BuiltInParameterGroup.PG_MECHANICAL);
            groupParameters.Add(BuiltInParameterGroup.PG_MECHANICAL_LOADS);
            groupParameters.Add(BuiltInParameterGroup.PG_MECHANICAL_AIRFLOW);
            groupParameters.Add(BuiltInParameterGroup.PG_MOMENTS);
            groupParameters.Add(BuiltInParameterGroup.PG_COUPLER_ARRAY);
            groupParameters.Add(BuiltInParameterGroup.PG_REBAR_ARRAY);
            groupParameters.Add(BuiltInParameterGroup.PG_STRUCTURAL);
            groupParameters.Add(BuiltInParameterGroup.PG_OVERALL_LEGEND);
            groupParameters.Add(BuiltInParameterGroup.PG_GENERAL);
            groupParameters.Add(BuiltInParameterGroup.PG_PRIMARY_END);
            groupParameters.Add(BuiltInParameterGroup.PG_IFC);
            groupParameters.Add(BuiltInParameterGroup.INVALID);
            groupParameters.Add(BuiltInParameterGroup.PG_GEOMETRY);
            groupParameters.Add(BuiltInParameterGroup.PG_STRUCTURAL_ANALYSIS);
            groupParameters.Add(BuiltInParameterGroup.PG_ENERGY_ANALYSIS);
            groupParameters.Add(BuiltInParameterGroup.PG_SLAB_SHAPE_EDIT);
            groupParameters.Add(BuiltInParameterGroup.PG_ANALYSIS_RESULTS);
            groupParameters.Add(BuiltInParameterGroup.PG_PLUMBING);
            groupParameters.Add(BuiltInParameterGroup.PG_ADSK_MODEL_PROPERTIES);
            groupParameters.Add(BuiltInParameterGroup.PG_GREEN_BUILDING);
            groupParameters.Add(BuiltInParameterGroup.PG_SEGMENTS_FITTINGS);
            groupParameters.Add(BuiltInParameterGroup.PG_FORCES);
            groupParameters.Add(BuiltInParameterGroup.PG_FIRE_PROTECTION);
            groupParameters.Add(BuiltInParameterGroup.PG_REBAR_SYSTEM_LAYERS);
            groupParameters.Add(BuiltInParameterGroup.PG_RELEASES_MEMBER_FORCES);
            groupParameters.Add(BuiltInParameterGroup.PG_PHASING);
            groupParameters.Add(BuiltInParameterGroup.PG_CONSTRUCTION);
            groupParameters.Add(BuiltInParameterGroup.PG_TEXT);
            groupParameters.Add(BuiltInParameterGroup.PG_LIGHT_PHOTOMETRICS);
            groupParameters.Add(BuiltInParameterGroup.PG_TITLE);
            groupParameters.Add(BuiltInParameterGroup.PG_ELECTRICAL_ENGINEERING);
            groupParameters.Add(BuiltInParameterGroup.PG_ELECTRICAL);
            groupParameters.Add(BuiltInParameterGroup.PG_ELECTRICAL_LOADS);
            groupParameters.Add(BuiltInParameterGroup.PG_ELECTRICAL_LIGHTING);
            groupParameters.Add(BuiltInParameterGroup.PG_ELECTRICAL_CIRCUITING);

            return groupParameters;
        }

 

0 Likes
Message 6 of 8

sragan
Collaborator
Collaborator

I'm not sure how you would get extra elements.

 

But with the code you were using, if a particular parameter group isn't used in any elements in the project you have open, it's not going to include that parameter group.

 

0 Likes
Message 7 of 8

GaryOrrMBI
Collaborator
Collaborator

2023 and prior had a BuiltinParameterGroup Enumeration that you could parse through.
That Enum no longer exists as they have fully transitioned to ForgeTypeId to define these values.

I have not found a method of parsing those or separating them by what they apply to (everything that uses ForgeTypeId all gets lumped together).

 

Here is a snippet in VB that I used to be able to use to print them out (similar for any of the former Enums, most of which have been replaced by ForgeTypeId references and can no longer be acquired in such a manner) to a txt file:

 

		'start a log file:
		Dim logFile As System.IO.FileInfo = New System.IO.FileInfo(My.Computer.FileSystem.CombinePath("C:\Temp", "Built In Parameters.txt"))
		Dim writer As System.IO.StreamWriter = logFile.CreateText()

		writer.WriteLine(vbCr & "*** Built In Parameter Groups ***" & vbCr)
		For Each item As BuiltInParameterGroup In [Enum].GetValues(GetType(BuiltInParameterGroup))
			writer.WriteLine(item & "  Enum Name:  " & item.ToString)
			writer.WriteLine(vbTab & "- Display Name: " & LabelUtils.GetLabelFor(item))
		Next

 

-G

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes
Message 8 of 8

2lenin-off
Enthusiast
Enthusiast

Thank you all very much for your help!

If anyone is interested: I made a plugin for batch adding parameters to a family and saving presets for such parameter additions. I'll be glad if this is useful to someone.

https://github.com/xPRYANIKx/RevitRibbonParametersManager

0 Likes