Hello
How can I get Grids from a List of Elements that I got with PickObjects method?
IList<Element> elemen_x = new List<Element>();
Selection sel = uidoc.Selection;
var axis_x = sel.PickObjects(ObjectType.Element).ToList();
foreach(Reference e in axis_x)
{
var ele = doc.GetElement(e);
elemen_x.Add(ele);
}
Solved! Go to Solution.
Solved by RPTHOMAS108. Go to Solution.
If you only want grids you can use the ISeletionFilter.
https://www.revitapidocs.com/2015/8038c1e1-262e-5d25-c065-b75b9ba98603.htm
Or you can use if check to see if it's a grid:
foreach(Reference e in axis_x)
{
If(doc.GetElement(e) is Grid grid)
{
elemen_x.Add(grid);
}
}
Thanks @RPTHOMAS108 . It was indeed the casting to Grids. Also what you suggest @Sean_Page is very usefull for me!
Can't find what you're looking for? Ask the community or share your knowledge.