Document Get |
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: 25.0.0.0 (25.0.0.0)

Parameters
- baseVersionGUID Guid
- 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
DocumentDifferenceAn object containing collections of the created, modified and deleted ids between the input version and current version.

Exception | Condition |
---|---|
ArgumentException | This GUID is invalid in the given document. |

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);
}
