Can I create a ParameterSet using multiple parameters obtained w/GetParameters?

rita.aguiar
Advocate
Advocate

Can I create a ParameterSet using multiple parameters obtained w/GetParameters?

rita.aguiar
Advocate
Advocate

I would like to create a List<string> with several strings corresponding to different parameter names of an element.

The elements in my Revit model have a few parameters (created with the Autodesk Classification Manager for Revit), which I would like to get, and add to the List<string> paramNames.

(Attached .png also shows the code)

  

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

foreach (Element e in elementSet)
{
    ParameterSet parameters = e.GetParameters("Classification.Uniclass.Ss.Number",
                                              "Classification.Uniclass.EF.Number",
                                              "Classification.Uniclass.Ss.Description",
                                              "Classification.Uniclass.Pr.Number",
                                              "Classification.Uniclass.Pr.Description");
//GetParameters only takes one argument so I can't do it like I have been trying //How can I get more than one parameter to create a ParameterSet? foreach (Parameter parameter in parameters) { name = parameter.Definition.Name; if (!paramNames.Contains(name)) { paramNames.Add(name); } } } paramNames.Sort();

 

Any help would be appretiated!

 

 

0 Likes
Reply
Accepted solutions (1)
963 Views
3 Replies
Replies (3)

naveen.kumar.t
Autodesk Support
Autodesk Support

hi @rita.aguiar,

can you try using the below code

List<string> para_names = new List<string>();
IList<Element> elements;
                foreach(Element e in elements)
                {
                    foreach(Parameter p in e.Parameters)
                    {
                        string para_name = p.Definition.Name;
                        if(para_name!=null)
                        {
                            if(!para_names.Contains(para_name))
                            {
                                para_names.Add(para_name);
                            }
                        }
                    }
                }
                para_names.Sort();

Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

rita.aguiar
Advocate
Advocate

Thank you @naveen.kumar.t

 

If I understood correctly, your code will get all parameters of an element using e.Parameters.

However, I would like to only get a few (the 5 paramater named "Classification.Uniclass.Ss.Number", "Classification.Uniclass.EF.Number", "Classification.Uniclass.Ss.Description", "Classification.Uniclass.Pr.Number", and "Classification.Uniclass.Pr.Description").

 

On a side note, the variable 'elements' is local so I get an error saying that "it cannot be declared in this scope because it is used in an enclosed local scope to define a local or parameter".

 

 

0 Likes

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @rita.aguiar,

are you looking for this?????

 

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

                List<string> Interested_Parameter_names = new List<string>();
                Interested_Parameter_names.Add("Classification.Uniclass.Ss.Number");
                Interested_Parameter_names.Add("Classification.Uniclass.EF.Number");
                Interested_Parameter_names.Add("Classification.Uniclass.Ss.Description");
                Interested_Parameter_names.Add("Classification.Uniclass.Pr.Number");
                Interested_Parameter_names.Add("Classification.Uniclass.Pr.Description");

              
                IList<ElementId> eids = sf.GetElementIds() as IList<ElementId>;
                foreach(ElementId eid in eids)
                {
                    Element e = doc.GetElement(eid);
                    foreach(Parameter p in e.Parameters)
                    {
                        if(Interested_Parameter_names.Contains(p.Definition.Name))
                        {
                            if(!final_parameter_name_list.Contains(p.Definition.Name))
                            {
                                final_parameter_name_list.Add(p.Definition.Name);
                            }
                           
                        }
                    }
                }

final_parameter_list contains list of parameters but here in the list , parameter names are not repeated.

 

 

 

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes