Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get grids form PickObjects Selection

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
luisdavid.mena
568 Views, 3 Replies

Get grids form PickObjects Selection

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

 

Tags (2)
Labels (1)
3 REPLIES 3
Message 2 of 4
Message 3 of 4
Sean_Page
in reply to: luisdavid.mena

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

 

 

 

 

Message 4 of 4

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.

Post to forums  

Rail Community


Autodesk Design & Make Report