Skip to content

Commit 8acbc17

Browse files
authored
Snippet_FilterSelect
This works just as Filter Selection but in Reverse. It allows you to first select the Category of the Selection by picking up an Object of that Category and follow up with a standard rectangular selection. After finishing the selection, only objects from that Category will be selected.
1 parent 660d984 commit 8acbc17

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Make a selection of objects in view filtering by category
3+
This works just as Filter Selection but in Reverse. It allows you to first select the Category of the Selection by
4+
picking up an Object of that Category and follow up with a standard rectangular selection. After finishing the selection, only
5+
objects from that Category will be selected.
6+
TESTED REVIT API: 2018
7+
The snippet can be used as is in a Revit Application Macro for test purposes
8+
Author: Deyan Nenov | github.com/ArchilizerLtd
9+
This file is shared on www.revitapidocs.com
10+
For more information visit http://github.com/gtalarico/revitapidocs
11+
License: http://github.com/gtalarico/revitapidocs/blob/master/LICENSE.md
12+
*/
13+
14+
public void FilterSelect()
15+
{
16+
UIDocument uidoc = ActiveUIDocument;
17+
Document doc = uidoc.Document;
18+
19+
Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "Set the filter"); //Pick an object by which Category you will filter
20+
21+
IList<Element> elements = uidoc.Selection.PickElementsByRectangle();
22+
23+
uidoc.Selection.SetElementIds(elements
24+
.Where(x => x.Category.Id.IntegerValue.Equals(doc.GetElement(refer).Category.Id.IntegerValue))
25+
.Select(x => x.Id)
26+
.ToList());
27+
}

0 commit comments

Comments
 (0)