The Autodesk.Revit.DB.DocumentVersion class represents a version of a Revit document. It is typically used when collaborating with other users on a shared Revit model.
The Autodesk.Revit.DB.DocumentVersion class has the following properties:
CurrentVersion: Gets the current version of the document, which is the version that other users will see when they open the document.LocalVersion: Gets the local version of the document, which is the version that the currently logged in user has saved to their computer.ServerVersion: Gets the server version of the document, which is the version that is saved on the shared network location.The Autodesk.Revit.DB.DocumentVersion class has the following methods:
Reload(): Reloads the document from the server, discarding any local changes.SaveAsLocal(): Saves the current version of the document as the local version.SaveAsNewServerVersion(): Saves the current version of the document as a new server version.// Get the current document
Document doc = commandData.Application.ActiveUIDocument.Document;
// Get the current document version
DocumentVersion currentVersion = doc.GetDocumentVersion();
// Output the current version numbers to the console
TaskDialog.Show("Document Versions", $"CurrentVersion: {currentVersion.CurrentVersion} \nLocalVersion: {currentVersion.LocalVersion} \nServerVersion: {currentVersion.ServerVersion}");
// Save the current version as the local version
currentVersion.SaveAsLocal();