Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Transaction(TransactionMode.Manual)]
public class test : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
commandData.Application.DialogBoxShowing += new EventHandler<DialogBoxShowingEventArgs>(OnDialogShowing);
commandData.Application.Application.FailuresProcessing += new EventHandler<FailuresProcessingEventArgs>(OnFailuresProcessing);
commandData.Application.Application.FailuresProcessing -= OnFailuresProcessing;
commandData.Application.DialogBoxShowing -= OnDialogShowing;
return Result.Succeeded;
}
private static void OnFailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e)
{
FailuresAccessor failuresAccessor = e.GetFailuresAccessor();
IEnumerable<FailureMessageAccessor> failureMessages = failuresAccessor.GetFailureMessages();
foreach (FailureMessageAccessor failureMessage in failureMessages)
{
if (failureMessage.GetSeverity() == FailureSeverity.Warning)
{
failuresAccessor.DeleteWarning(failureMessage);
}
}
e.SetProcessingResult(FailureProcessingResult.Continue);
}
private static void OnDialogShowing(object o, DialogBoxShowingEventArgs e)
{
if (e.Cancellable)
{
e.Cancel();
}
//worry about this later - 1002 = cancel
if (e.DialogId == "TaskDialog_Unresolved_References")
{
e.OverrideResult(1002);
}
//Don't sync newly created files. 1003 = close
if (e.DialogId == "TaskDialog_Local_Changes_Not_Synchronized_With_Central")
{
e.OverrideResult(1003);
}
if (e.DialogId == "TaskDialog_Save_Changes_To_Local_File")
{
//Relinquish unmodified elements and worksets
e.OverrideResult(1001);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment