A unique identifier for an Element in an Autodesk Revit project.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic ElementId Id { get; }
Public ReadOnly Property Id As ElementId
Get
public:
property ElementId^ Id {
ElementId^ get ();
}
member Id : ElementId with get
Property Value
ElementId
Remarks
Returns an object containing the project-wide unique identifier for this Element. The identifier with this id is only unique for the project, it is not unique across separate Autodesk Revit projects.
Exampleprivate void CheckElementId(Autodesk.Revit.DB.Document document, Autodesk.Revit.DB.Element element)
{
Autodesk.Revit.DB.ElementId selectedId = element.Id;
long idValue = selectedId.Value;
Autodesk.Revit.DB.ElementId id = new Autodesk.Revit.DB.ElementId(idValue);
Autodesk.Revit.DB.Element first = document.GetElement(id);
Autodesk.Revit.DB.Element second = document.GetElement(selectedId);
String prompt = "Get an element twice. They should be the same element.";
bool isSame = first.Equals(second);
prompt += "\nUsing Equal method on elements, the result is: " + isSame;
isSame = first.Id.Equals(second.Id);
prompt += "\nUsing Equal method on element's Id properties, the result is: " + isSame;
TaskDialog.Show("Revit",prompt);
}
Private Sub CheckElementId(document As Autodesk.Revit.DB.Document, element As Autodesk.Revit.DB.Element)
Dim selectedId As Autodesk.Revit.DB.ElementId = element.Id
Dim idValue As Long = selectedId.Value
Dim id As New Autodesk.Revit.DB.ElementId(idValue)
Dim first As Autodesk.Revit.DB.Element = document.GetElement(id)
Dim second As Autodesk.Revit.DB.Element = document.GetElement(selectedId)
Dim prompt As [String] = "Get an element twice. They should be the same element."
Dim isSame As Boolean = first.Equals(second)
prompt += vbLf & "Using Equal method on elements, the result is: " & isSame
isSame = first.Id.Equals(second.Id)
prompt += vbLf & "Using Equal method on element's Id properties, the result is: " & isSame
TaskDialog.Show("Revit", prompt)
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