
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey everyone!
I'm working on a plug-in that enables this process: the user opens an empty Revit file / a template > the user runs my plug-in > the plug-in opens a file in the background > the plug-in extracts some data from the document > the plug-in closes the document > the plug-in open the next document > and so on...
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.
Luckily I found these two resources: https://www.revitapidocs.com/2015/446796ca-d8f5-0f8a-7b82-a4ec6e5aa7a0.htm and https://thebuildingcoder.typepad.com/blog/2016/09/warning-swallower-and-roomedit3d-viewer-extension....
so I implemented this "warnings swallower" that solves this issue:
In App.cs
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<FailuresProcessingEventArgs>(ResolveOpeningWarnings); return Result.Succeeded; } private void ResolveOpeningWarnings(object sender, FailuresProcessingEventArgs e) { FailuresAccessor fa = e.GetFailuresAccessor(); IList<FailureMessageAccessor> failList = fa.GetFailureMessages(); foreach (FailureMessageAccessor failure in failList) { FailureSeverity fSeverity = failure.GetSeverity(); if (fSeverity == FailureSeverity.Warning) { fa.DeleteWarning(failure); } else { fa.ResolveFailure(failure); } } }
which actually works a treat.
The real problem is this: 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 😄
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?
I hope this actually makes sense.
Thanks,
Andrea
Solved! Go to Solution.