Options to customize Revit behavior when accessing the central model.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 19.0.0.0 (19.0.0.405)
Since:
2014
Syntax
C# |
---|
public class TransactWithCentralOptions : IDisposable |
Visual Basic |
---|
Public Class TransactWithCentralOptions _
Implements IDisposable |
Visual C++ |
---|
public ref class TransactWithCentralOptions : IDisposable |
Examples
CopyC#
public static void SynchWithCentralWithMessage(Document doc)
{
FilteredWorksetCollector fwc = new FilteredWorksetCollector(doc);
fwc.OfKind(WorksetKind.UserWorkset);
Workset workset1 = fwc.First<Workset>(ws => ws.Name == "Workset1");
WorksharingUtils.CheckoutWorksets(doc, new WorksetId[] { workset1.Id });
using (Transaction t = new Transaction(doc, "Add Level"))
{
t.Start();
Level.Create(doc, 100);
t.Commit();
}
TaskDialog td = new TaskDialog("Alert");
td.MainInstruction = "Application 'Automatic element creator' has made changes and is prepared to synchronize with central.";
td.MainContent = "This will update central with all changes currently made in the project by the application or by the user. This operation " +
"may take some time depending on the number of changes made by the app and by the user.";
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Do not synchronize at this time.");
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Synchronize and relinquish all elements.");
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink3, "Synchronize but keep checked out worksets.");
td.DefaultButton = TaskDialogResult.CommandLink1;
TaskDialogResult result = td.Show();
switch (result)
{
case TaskDialogResult.CommandLink1:
default:
{
break;
}
case TaskDialogResult.CommandLink2:
case TaskDialogResult.CommandLink3:
{
TransactWithCentralOptions twcOpts = new TransactWithCentralOptions();
SynchronizeWithCentralOptions swcOpts = new SynchronizeWithCentralOptions();
swcOpts.Comment = "Synchronized by 'Automatic element creator' with user acceptance.";
if (result == TaskDialogResult.CommandLink3)
{
RelinquishOptions rOptions = new RelinquishOptions(true);
rOptions.UserWorksets = false;
swcOpts.SetRelinquishOptions(rOptions);
}
doc.SynchronizeWithCentral(twcOpts, swcOpts);
break;
}
}
}
CopyVB.NET
Public Shared Sub SynchWithCentralWithMessage(doc As Document)
Dim fwc As New FilteredWorksetCollector(doc)
fwc.OfKind(WorksetKind.UserWorkset)
Dim workset1 As Workset = fwc.First(Function(ws) ws.Name = "Workset1")
WorksharingUtils.CheckoutWorksets(doc, New WorksetId() {workset1.Id})
Using t As New Transaction(doc, "Add Level")
t.Start()
Level.Create(doc, 100)
t.Commit()
End Using
Dim td As New TaskDialog("Alert")
td.MainInstruction =
td.MainContent = "This will update central with all changes currently made in the project by the application or by the user. This operation " + "may take some time depending on the number of changes made by the app and by the user."
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Do not synchronize at this time.")
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Synchronize and relinquish all elements.")
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink3, "Synchronize but keep checked out worksets.")
td.DefaultButton = TaskDialogResult.CommandLink1
Dim result As TaskDialogResult = td.Show()
Select Case result
Case TaskDialogResult.CommandLink1
If True Then
Exit Select
End If
Case TaskDialogResult.CommandLink2, TaskDialogResult.CommandLink3
If True Then
Dim twcOpts As New TransactWithCentralOptions()
Dim swcOpts As New SynchronizeWithCentralOptions()
swcOpts.Comment =
If result = TaskDialogResult.CommandLink3 Then
Dim rOptions As New RelinquishOptions(True)
rOptions.UserWorksets = False
swcOpts.SetRelinquishOptions(rOptions)
End If
doc.SynchronizeWithCentral(twcOpts, swcOpts)
Exit Select
End If
End Select
End Sub
Inheritance Hierarchy
See Also