Getting Property of Element Type

Getting Property of Element Type

Anonymous
Not applicable
4,727 Views
5 Replies
Message 1 of 6

Getting Property of Element Type

Anonymous
Not applicable

Hi, it's me again 🙂

 

I'm wondering how i can achieve the fact to acces to the type of a element property.

I'm getting a list of Element by : 

m_elementsToProcess = collector.OfCategory(BuiltInCategory.OST_Roofs).WhereElementIsNotElementType().ToElements();

 

I didn't found something in the SDK sample, neither online, i dont' know if my process is wrong..

 

Could you help me ?

 

But i don't kno

 

 

PS :

I mean this property : 

 

[url=https://www.noelshack.com/2018-25-1-1529324956-propertytype.png][img]https://image.noelshack.com/min...]

0 Likes
Accepted solutions (1)
4,728 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

You can get element properties by using the following code

foreach(ElementId eid in m_elementsToProcess)
                    {
                        Element e = doc.GetElement(eid);
                        foreach(Parameter p in e.Parameters)
                        {
                            s = s + p.Definition.Name + "   " + p.AsValueString() + "\n";
                        }
                        TaskDialog.Show("points", s);
                    }

and if you want to change the value of the parameter

foreach (Parameter p in e.Parameters)
                        {
                            if(p.Definition.Name=="Slope")
                            {
                                p.SetValueString("18");
                            }
                        }
0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi ! 

 

Thanks for reply.

 

Sorry, I think i didn't explain my issue clearly.

 

When I use your code, i'm getting the property of the element of my document.

But here, i want to get the property of the type of this element 🙂

 

Regards,

Maxence

 

0 Likes
Message 4 of 6

Anonymous
Not applicable

try using this code

 Element e = doc.GetElement(eid);
                        Element et = e.Document.GetElement(e.GetTypeId());
                        foreach(Parameter p in et.Parameters)
                        {
                            s = s + p.Definition.Name + "   " + p.AsValueString() + "\n";
                        }
                        TaskDialog.Show("points", s);
0 Likes
Message 5 of 6

Anonymous
Not applicable
Accepted solution

Hi !

 

I just figured out by myself (reading a post online)

 

Thanks for help anyway !

 

 

private void test(Element e)
            {
                //ParameterSet parameters = e.Parameters;
                ElementType et = m_doc.GetElement(e.GetTypeId()) as ElementType;
                ParameterSet parameters = et.Parameters;


                StringBuilder sb = new StringBuilder();
                foreach (Parameter param in parameters)
                {
                    if (param.Definition.Name == "Code composant_PA")
                        sb.AppendFormat("{0}  -  {1}\n", param.Definition.Name, param.AsValueString());
                }

                TaskDialog.Show("points", sb.ToString());
                
            }

 

0 Likes
Message 6 of 6

Anonymous
Not applicable

I tryed get value using p.AsValueString(), but returned null, but here works with p.AsString() on Revit 2021

0 Likes