<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Failure Processing / Warnings Swallower only for specific files in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8872506#M41455</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Dear Andrea,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your update.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;No, by no way bad, I think it is perfect.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Not in any way unorthodox at all.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Perfect solution, a very nice example of flexible&amp;nbsp; and optimised event handling.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jun 2019 04:57:14 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2019-06-26T04:57:14Z</dc:date>
    <item>
      <title>Failure Processing / Warnings Swallower only for specific files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8870050#M41451</link>
      <description>&lt;P&gt;Hey everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on a plug-in that enables this process: the user opens an empty Revit file / a template &amp;gt; the user runs my plug-in &amp;gt; the plug-in opens a file in the background &amp;gt; the plug-in extracts some data from the document &amp;gt; the plug-in closes the document &amp;gt; the plug-in open the next document &amp;gt; and so on...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've had some problems when running multiple files overnight cause the plug-in was trying to open one file, but that gave a warning (like 81 rooms not enclosed for example) and expected the user to simply click Ok and the whole night was wasted as the plug-in just waited for input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Luckily I found these two resources:&amp;nbsp;&lt;A href="https://www.revitapidocs.com/2015/446796ca-d8f5-0f8a-7b82-a4ec6e5aa7a0.htm" target="_blank"&gt;https://www.revitapidocs.com/2015/446796ca-d8f5-0f8a-7b82-a4ec6e5aa7a0.htm&lt;/A&gt;&amp;nbsp; &amp;nbsp;and&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;A href="https://thebuildingcoder.typepad.com/blog/2016/09/warning-swallower-and-roomedit3d-viewer-extension.html#2" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2016/09/warning-swallower-and-roomedit3d-viewer-extension.html#2&lt;/A&gt;&lt;/P&gt;&lt;P&gt;so I implemented this "warnings swallower" that solves this issue:&lt;/P&gt;&lt;P&gt;In App.cs&lt;/P&gt;&lt;PRE&gt;        public Result OnStartup(UIControlledApplication application)
        {
            // Load toolbox at startup
            AddPluginPanel(application);

            //Create an API application that subscribes to FailuresProcessing event for the lifetime of the session.
            application.ControlledApplication.FailuresProcessing += 
                new EventHandler&amp;lt;FailuresProcessingEventArgs&amp;gt;(ResolveOpeningWarnings);

            return Result.Succeeded;
        }

        private void ResolveOpeningWarnings(object sender, FailuresProcessingEventArgs e)
        {
            FailuresAccessor fa = e.GetFailuresAccessor();
            IList&amp;lt;FailureMessageAccessor&amp;gt; failList = fa.GetFailureMessages();
            foreach (FailureMessageAccessor failure in failList)
            {
                FailureSeverity fSeverity = failure.GetSeverity();

                if (fSeverity == FailureSeverity.Warning)
                {
                    fa.DeleteWarning(failure);
                }
                else
                {
                    fa.ResolveFailure(failure);
                }
            }
        }&lt;/PRE&gt;&lt;P&gt;which actually works a treat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The real problem is this:&lt;/STRONG&gt; Now everytime I'll open any file and I'll encounter a warning I won't be aware of it (I could write them to some text file for example, but it's not ideal). Same for all the people I'll give this plug-in to. And they'll get angry &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to be selective with this swallower and apply it only to the files I'm opening in the background through that specific plugin? And not to the files that get opened by any Revit application that has that plug-in loaded?&lt;BR /&gt;&lt;BR /&gt;I hope this actually makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrea&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 07:25:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8870050#M41451</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-25T07:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Failure Processing / Warnings Swallower only for specific files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8870185#M41452</link>
      <description>&lt;P&gt;Just as you use += to subscribe to the event, you can use -= to unsubscribe again at any time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thus, you can turn on and off your warning swallower at will.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, you can turn it on and off when specific documents are opened and closed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 08:10:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8870185#M41452</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-06-25T08:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Failure Processing / Warnings Swallower only for specific files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8872184#M41453</link>
      <description>&lt;P&gt;So there's no way to "assign" the event to specific documents when the button's method is called? Instead of "assigning" it at StartUp?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 23:24:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8872184#M41453</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-25T23:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Failure Processing / Warnings Swallower only for specific files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8872258#M41454</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/413917"&gt;@jeremytammik&lt;/a&gt;&amp;nbsp;I tried something, which actually looks quite unorthodox to me and I don't know if it's the right thing to do...but it works!&lt;/P&gt;&lt;P&gt;I'll write it down here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of subscribing the event from the OnStartup method, I created a&amp;nbsp;&lt;EM&gt;public static&lt;/EM&gt; variable in the &lt;EM&gt;App&lt;/EM&gt; class and I assign to it the&amp;nbsp;&lt;EM&gt;UIControlledApplication&lt;/EM&gt; to it in&amp;nbsp;&lt;EM&gt;OnStartup&lt;/EM&gt;.&lt;/P&gt;&lt;PRE&gt;class App : IExternalApplication
{
    public static UIControlledApplication app;

    public Result OnStartup(UIControlledApplication application)
    {&lt;BR /&gt;        app = application;&lt;BR /&gt;
        // Load toolbox at startup
        AddPluginPanel(application);

        return Result.Succeeded;
    }
}&lt;/PRE&gt;&lt;P&gt;Then, in the&amp;nbsp;&lt;EM&gt;Execute&lt;/EM&gt; method, if the user starts the process I subscribe the event to the application, and when the process finishes I unsubscribe the event in the way you showed in your comment:&lt;/P&gt;&lt;PRE&gt;        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document doc = uidoc.Document;

            // Prompt user to set theaudit up
            Setup setup = new Setup();
            setup.ShowDialog();

            if (setup.&lt;STRONG&gt;started&lt;/STRONG&gt;)
            {
                // Assign method to suppress opening warnings when audit process starts
                App.app.ControlledApplication.FailuresProcessing &lt;STRONG&gt;+=&lt;/STRONG&gt;
                    new EventHandler&amp;lt;FailuresProcessingEventArgs&amp;gt;(ResolveOpeningWarnings);

                success = ProcessRun.Run(app);
            }
            else
            {
                Messages.ErrorMessage("User cancelled");

                // Unsubscribe method when it's done
                App.app.ControlledApplication.FailuresProcessing &lt;STRONG&gt;-=&lt;/STRONG&gt;
                    new EventHandler&amp;lt;FailuresProcessingEventArgs&amp;gt;(ResolveOpeningWarnings);

                return Result.Cancelled;
            }
        }&lt;/PRE&gt;&lt;P&gt;I hope the above is understandable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it bad?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrea&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 00:46:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8872258#M41454</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-26T00:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Failure Processing / Warnings Swallower only for specific files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8872506#M41455</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear Andrea,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your update.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;No, by no way bad, I think it is perfect.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Not in any way unorthodox at all.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Perfect solution, a very nice example of flexible&amp;nbsp; and optimised event handling.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 04:57:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8872506#M41455</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-06-26T04:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Failure Processing / Warnings Swallower only for specific files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8872547#M41456</link>
      <description>&lt;P&gt;I might cry now &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help and the right direction Jeremy!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 05:36:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/failure-processing-warnings-swallower-only-for-specific-files/m-p/8872547#M41456</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-26T05:36:13Z</dc:date>
    </item>
  </channel>
</rss>

