Get parameter values

Get parameter values

Hariharan_RadhakrishnanPCEKW
Participant Participant
3,210 Views
3 Replies
Message 1 of 4

Get parameter values

Hariharan_RadhakrishnanPCEKW
Participant
Participant

I need to get Parameter values of the Element, When I tried in Python inside dynamo, it is possible by using 

 

paramNames = []
params = ele.Parameters;
for param in params:
    paramNames.Add(param.Definition.Name)

 

same thing, if I tried to get in C#, there I am getting Error

 

FilteredElementCollector foc = new FilteredElementCollector(d).OfCategory(BuiltInCategory.OST_PipeCurves).WhereElementIsNotElementType();

List<Element> pipeElement = foc.ToElements().ToList();

foreach(Element pEle in pipeElement)
{
List<Parameter> para = new List<Parameter>();

ParameterSet pd = pEle.Parameters;

foreach (ParameterSet ele in pd)
{

ele.Definition

}

}

0 Likes
Accepted solutions (2)
3,211 Views
3 Replies
Replies (3)
Message 2 of 4

RPTHOMAS108
Mentor
Mentor
Accepted solution

In a type safe language when you declare types they have to be the right types (can be cast to). I think this is just a minor error as below:

 

foreach (ParameterSet ele in pd)
{
Definition Def = ele.Definition

}

}

 

Then you need to do something with the Definition within the foreach loop but I don't think you actually need the definition if all you are aiming to do is get the value from the parameter 'ele' but you are getting the name not the value so perhaps that is my confusion?

 

Would be easier to understand if 'ele' was instead called something similar to 'Param' and 'pipeElement' was plural to indicate it is a collection not a single object.

 

None of this has anything to do with the RevitAPI, if you are learning C# or the consequences of using it instead of Python then there are better places to start in my view. Learn the syntax and principles of language first and then add the RevitAPI specifics would be my approach.

0 Likes
Message 3 of 4

caroline.gitonga
Autodesk
Autodesk
Accepted solution

Hi @Hariharan_RadhakrishnanPCEKW ,

foreach (Element pEle in pipeElement)
{

foreach (Parameter param in pEle.Parameters)
{

string paramName = param.Definition.Name;

}

}

Carol Gitonga, Developer Advocacy and Support, ADN Open
0 Likes
Message 4 of 4

Hariharan_RadhakrishnanPCEKW
Participant
Participant

Thank you so much for your kind reply and Suggestions