Get grids form PickObjects Selection

luisdavid.mena
Enthusiast
Enthusiast

Get grids form PickObjects Selection

luisdavid.mena
Enthusiast
Enthusiast

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);
}

 

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

RPTHOMAS108
Mentor
Mentor
Accepted solution
0 Likes

Sean_Page
Collaborator
Collaborator

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);
        }
}

 

 

 

 

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect

luisdavid.mena
Enthusiast
Enthusiast

Thanks @RPTHOMAS108  . It was indeed the casting to Grids. Also what you suggest @Sean_Page  is very usefull for me!

0 Likes