Skip to content

Instantly share code, notes, and snippets.

@chuongmep
Created June 9, 2022 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuongmep/7f2a122d69ae710acc5fd84b7dba3ec4 to your computer and use it in GitHub Desktop.
Save chuongmep/7f2a122d69ae710acc5fd84b7dba3ec4 to your computer and use it in GitHub Desktop.
[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