Filter elements where clause

Filter elements where clause

Anonymous
Not applicable
587 Views
1 Reply
Message 1 of 2

Filter elements where clause

Anonymous
Not applicable

Hi,

I don;t know what am I doing wrong but I am trying to get a FilteredElementCollector with multiple where clause but its not working:

                        Element Ele = new FilteredElementCollector(Command.doc, Command.doc.ActiveView.Id).WhereElementIsElementType().ToElements().Where(o => o.LookupParameter("Diameter").AsString() == "150 mm" && o.LookupParameter("TEXT").AsString() == "NORTH BOUND TRACK LEVEL").First();

Thanks & Regards

Sanjay Pandey

0 Likes
588 Views
1 Reply
Reply (1)
Message 2 of 2

Moustafa_K
Advisor
Advisor
@sanjaymannwrote:

Dear mostafa,

I am trying to select all elements in the document with particular parameters name and values I tried this but failed. can you please help me out.

 

                        Element Ele = new FilteredElementCollector(Command.doc, Command.doc.ActiveView.Id).WhereElementIsElementType().ToElements().Where(o => o.LookupParameter("Diameter").AsString() == "150 mm" && o.LookupParameter("TEXT").AsString() == "NORTH BOUND TRACK LEVEL").First();

Thanks & Regards

 

Sanjay Pandey

Hi

First you mentioned All Element and not Element Type: so you need to change "WhereElementIsElementType()" to "WhereElementsISnotElementType"

Second: you mention all Element in the Document and not View Specific:  you need to omit "Command.doc.ActiveView.Id"

Third double check : Spelling mistake and Case Sensitive.

Last: If Diameter is a builtin Parameter, then you need to look into the the right builtinDefinition as it is more safe to find the exact value.

 

Hope this helps

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes