Element.UniqueId Property

ElementUniqueId Property

A stable unique identifier for an element within the document.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public string UniqueId { get; }
Public ReadOnly Property UniqueId As String
	Get
public:
property String^ UniqueId {
	String^ get ();
}
member UniqueId : string with get

Property Value

String
Remarks
The UniqueId can be used to store an identifier in an external database and to retrieve the same element in the future if it still exists. This id can be passed to the Document's Element property to retrieve the element. The UniqueId is stable across upgrades and workset operations such as Save To Central, while the ElementId property may change.
Example
private void CheckElementUniqueId(Autodesk.Revit.DB.Document document, Autodesk.Revit.DB.Element element)
{
    String uniqueId = element.UniqueId;

    // Get the element using the UniqueId
    Autodesk.Revit.DB.Element elem = document.GetElement(uniqueId);

    String prompt = "UniqueId of element is: " + uniqueId;
    prompt += "\nUniqueID of elem is: " + elem.UniqueId;
}
Private Sub CheckElementUniqueId(document As Autodesk.Revit.DB.Document, element As Autodesk.Revit.DB.Element)
    Dim uniqueId As [String] = element.UniqueId

    ' Get the element using the UniqueId
    Dim elem As Autodesk.Revit.DB.Element = document.GetElement(uniqueId)

    Dim prompt As [String] = "UniqueId of element is: " & uniqueId
    prompt += vbLf & "UniqueID of elem is: " + elem.UniqueId
End Sub

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

See Also