Share

ElementSet Class

A set that contains element objects.

Inheritance Hierarchy

System.Object
  Autodesk.Revit.DB.APIObject
    Autodesk.Revit.DB.ElementSet


Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.3.0.0 (25.3.0.0)

Syntax

C#

public class ElementSet : APIObject, IEnumerable

The ElementSet type exposes the following members.

Constructors

 NameDescription
Public methodElementSetInitializes a new instance of the ElementSet class

Properties

 NameDescription
Public propertyIsEmptyTest to see if the set is empty.
Public propertyCode exampleIsReadOnlyIdentifies if the object is read-only or modifiable.
(Inherited from APIObject)
Public propertySizeReturns the number of elements that are in the set.

Methods

 NameDescription
Public methodClearRemoves every item element the set, rendering it empty.
Public methodContainsTests for the existence of an element within the set.
Public methodDisposeCauses the object to release immediately any resources it may be utilizing.
(Inherited from APIObject)
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodEraseRemoves a specified element from the set.
Public methodForwardIteratorRetrieve a forward moving iterator to the set.
Public methodGetEnumeratorRetrieve a forward moving iterator to the set.
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodInsertInsert the specified element into the set.
Public methodReverseIteratorRetrieve a backward moving iterator to the set.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)

Example

C#

ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds();

string info = "Selected elements:\n";
foreach (ElementId id in selectedIds)
{
    Element elem = document.GetElement(id);
    info += elem.Name + "\n";
}

TaskDialog.Show("Revit",info);

VB

Dim selectedIds As ICollection(Of ElementId) = uidoc.Selection.GetElementIds()

Dim info As String = "Selected elements:" & vbLf
For Each id As ElementId In selectedIds
    Dim elem As Element = document.GetElement(id)
    info += elem.Name + vbLf
Next

TaskDialog.Show("Revit", info)

See Also

Reference

Was this information helpful?