Exception is thrown when too many elements are requested for checkout
Namespace: Autodesk.Revit.Exceptions
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since: 2021
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Examples

void HandleCheckoutElementsRequestTooLargeException(Document doc)
{
FilteredElementCollector collector = new FilteredElementCollector(doc);
ICollection<ElementId> rooms = collector.WherePasses(new RoomFilter()).ToElementIds();
try
{
ICollection<ElementId> checkoutelements = WorksharingUtils.CheckoutElements(doc, rooms);
}
catch (Autodesk.Revit.Exceptions.CheckoutElementsRequestTooLargeException)
{
IEnumerable<WorksetId> worksets = rooms.Select(elemId => doc.GetWorksetId(elemId)).Distinct();
TaskDialog dlg = new TaskDialog("Elements can't be checked out")
{
MainInstruction = $"You are trying to check out a large number of elements. Instead check out the following {worksets.Count()} worksets:",
MainContent = string.Join(", ", worksets),
};
dlg.Show();
TransactWithCentralOptions twcOptions = new TransactWithCentralOptions();
ISet<WorksetId> worksetsCheckedout = WorksharingUtils.CheckoutWorksets(doc, worksets.ToHashSet(), twcOptions);
TaskDialog.Show(
title: "Worksets are checked out",
mainInstruction: $"{worksetsCheckedout.Count} worksets are checked out.");
}
}

Private Sub HandleCheckoutElementsRequestTooLargeException(ByVal doc As Document)
Dim collector As FilteredElementCollector = New FilteredElementCollector(doc)
Dim rooms As ICollection(Of ElementId) = collector.WherePasses(New RoomFilter()).ToElementIds()
Try
Dim checkoutelements As ICollection(Of ElementId) = WorksharingUtils.CheckoutElements(doc, rooms)
Catch __unusedCheckoutElementsRequestTooLargeException1__ As Autodesk.Revit.Exceptions.CheckoutElementsRequestTooLargeException
Dim worksets As IEnumerable(Of WorksetId) = rooms.[Select](Function(elemId) doc.GetWorksetId(elemId)).Distinct()
Dim dlg As TaskDialog = New TaskDialog("Elements can't be checked out") With {
.MainInstruction = $"You are trying to check out a large number of elements. Instead check out the following {worksets.Count()} worksets:",
.MainContent = String.Join(", ", worksets)
}
dlg.Show()
Dim twcOptions As TransactWithCentralOptions = New TransactWithCentralOptions()
Dim worksetsCheckedout As ISet(Of WorksetId) = WorksharingUtils.CheckoutWorksets(doc, worksets.ToHashSet(), twcOptions)
TaskDialog.Show(title:="Worksets are checked out", mainInstruction:=$"{worksetsCheckedout.Count} worksets are checked out.")
End Try
End Sub
Inheritance Hierarchy
SystemObject
SystemException
Autodesk.Revit.ExceptionsApplicationException
Autodesk.Revit.ExceptionsCentralModelException
Autodesk.Revit.ExceptionsCheckoutElementsRequestTooLargeException
SystemException
Autodesk.Revit.ExceptionsApplicationException
Autodesk.Revit.ExceptionsCentralModelException
Autodesk.Revit.ExceptionsCheckoutElementsRequestTooLargeException