forked from mayconrfreitas/RevitAPISnippets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetSelectedElements.snippet
More file actions
51 lines (44 loc) · 1.94 KB
/
GetSelectedElements.snippet
File metadata and controls
51 lines (44 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Get Selected Elements</Title>
<Author>Maycon Freitas</Author>
<Description>Gets the elements in the model.</Description>
<Shortcut>rvtgetsel</Shortcut>
</Header>
<Snippet>
<Code Language="CSharp">
<![CDATA[List<ElementId> $elementsIds$ = $uidoc$.Selection.GetElementIds()?.ToList() ?? new List<ElementId>();
List<Element> $selectedElements$ = $elementsIds$.Count > 0 ? $elementsIds$.Select(x => $doc$.GetElement(x)).ToList() : new List<Element>();]]>
</Code>
<Declarations>
<Literal>
<ID>elementsIds</ID>
<Default>elementsIds</Default>
<ToolTip>List to receive the ElementsIds of the selected elements in the model.</ToolTip>
</Literal>
<Literal>
<ID>uidoc</ID>
<Default>commandData.Application.ActiveUIDocument</Default>
<ToolTip>The current UIDocument (uidoc).</ToolTip>
</Literal>
<Literal>
<ID>selectedElements</ID>
<Default>selectedElements</Default>
<ToolTip>List to receive the elements from references list.</ToolTip>
</Literal>
<Literal>
<ID>doc</ID>
<Default>commandData.Application.ActiveUIDocument.Document</Default>
<ToolTip>The current Document (doc).</ToolTip>
</Literal>
</Declarations>
<Imports>
<Import>
<Namespace>Autodesk.Revit.DB</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>