Extracts a collection containing the ids of elements that have been created, modified or deleted between the input baseVersion and the document's current version.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since: 2023
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Parameters
- baseVersionGUID
- Type: SystemGuid
GUID of base version(excluded) to compare. This GUID should be retrieved from property [!:Autodesk::Revit::DB::DocumentVersion::VersoinGUID]. Empty GUID is allowed to retrieve changes of each version in the document.
Return Value
An object containing collections of the created, modified and deleted ids between the input version and current version.Examples

private void ShowChangedElements(Autodesk.Revit.DB.Document document, Guid baseVerseionGuid)
{
//Parameter baseVersionGuid is retrieved from property VersionGUID of Autodesk.Revit.DB.DocumentVersion.
//System.Guid.Empty is allowed to get all changes in document.
DocumentDifference docDiff = document.GetChangedElements(baseVerseionGuid);
if (docDiff.AreDeletedElementIdsAvailable)
{
TaskDialog.Show("Revit", "Deleted element history is available in current document.");
}
else
{
TaskDialog.Show("Revit", "Deleted element history is not available in current document.");
}
// New added elements.
var createdElementIds = docDiff.GetCreatedElementIds();
// Modified elements.
var modifiedElementIds = docDiff.GetModifiedElementIds();
// Deleted elements.
// For nonworkshared model, always returns an empty collection.
var deletedElementIds = docDiff.GetDeletedElementIds();
var changesetMessage = $"Found {createdElementIds.Count} new created elements, {modifiedElementIds.Count} modified elements and {deletedElementIds.Count} deleted elements.";
TaskDialog.Show("Revit", changesetMessage);
}

Private Sub ShowChangedElements(ByVal document As Document, ByVal baseVerseionGuid As Guid)
'Parameter baseVersionGuid is retrieved from property VersionGUID of Autodesk.Revit.DB.DocumentVersion.
'System.Guid.Empty is allowed to get all changes in document.
Dim docDiff = document.GetChangedElements(baseVerseionGuid)
If docDiff.AreDeletedElementIdsAvailable Then
TaskDialog.Show("Revit", "Deleted element history is available in current document.")
Else
TaskDialog.Show("Revit", "Deleted element history is not available in current document.")
End If
' New added elements.
Dim createdElementIds = docDiff.GetCreatedElementIds()
' Modified elements.
Dim modifiedElementIds = docDiff.GetModifiedElementIds()
' Deleted elements.
' For nonworkshared model, always returns an empty collection.
Dim deletedElementIds = docDiff.GetDeletedElementIds()
Dim changesetMessage = $"Found {createdElementIds.Count} new created elements, {modifiedElementIds.Count} modified elements and {deletedElementIds.Count} deleted elements."
TaskDialog.Show("Revit", changesetMessage)
End Sub
Exceptions
Exception | Condition |
---|---|
Autodesk.Revit.ExceptionsArgumentException | This GUID is invalid in the given document. |