Message 1 of 13

Not applicable
05-16-2013
08:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Unfortunately it's not. I've searched for it in the API and at AU last year confirmed that it isn't possible at the Revit API Roundtable. The best you can do it manually export the warnings list to html and create an add-in that reads that html file.
I also read through the What's New in the Revit 2014 API and didn't see anything mentioning it either.
If you can login to the AU site, I think it's mentioned in the class notes under 'Additional Class Materials'.
Please refer to the FailureProcessing event and related classes (FailuresAccessor, FailureResolution, etc.) in the API help.
For transactions own by your application, you can also pre-screen the list of failures using a FailuresPreprocessor. Please refer to the documentation for Transaction class, specifically to FailureHandlingOptions.SetFailuresPreprocessor
Thank you
Arnošt Löbel
Autodesk Revit R&D
Thanks Arnost.
Unfortunately we're trying to access warnings that occurred in the past and are stored in the document. These warnings or failures could have fired weeks ago and while the FailureProcessing event and FailuresPreprocessor assist with warnings your add-in may generate, it doesn't provide access to a list of failures that occurred in the past.
Hello Josef,
Thank you for the clarification. Indeed it is something different than what I thought it was, and we do not currently have an API for accessing past warnings. However, there may be a viable workaround that is probably worth exploring. Now, I have not tried it yet, but there is a “Review warnings” command somewhere in Revit which, when invoked, shows all those old warnings if any. Actually, how it does it is interesting – it does not just grab and show the warnings; instead it takes the warnings, posts them again, and let the standard failure handling mechanism do the displaying. So, it seems you might be able to get them after all. You would need to a) Write an event handler for the failure processing event. The event should be raised after the failures are posted and before the command’s transaction is finished. And you would also need to b) Programmatically invoke the “Review Warnings” command. I do not actually know if that command is one of those that could be invoked via the API, but chances are it is (I am talking R2014, of course). You may give it a try and see if it works like I expect it to.
If that does not work at all, and if there is more interest in the future, we will consider creating a specific API for it. (It had been considered before, but did not get a lot of attention.)
Arnošt Löbel
Autodesk Revit R&D
I am reading this: http://wikihelp.autodesk.com/Revit/enu/2014/Help/3665-Developers/0135-Advanced135/0153-Commands
It sounds like a command may be posted only after the API application execution is completed. So if this is the case, it will not be possible to embed it inside a transaction. Or am I missing something here?
A Revit command is posted during API execution, but, yes, it should be the last thing done and it is actuallyy executed only after the external command completes its execution.
You may not post a command from inside your transaction, but you should not need to, if I understand correctly what you try to achieve. You set up a failure handler, and you post the command. When the command gets executed, it'll start a transaction during which the old warnings are re-posted, upon which time your failure handler gets invoked. From the handler you can collect all failures using a failure accessor. Isn’t that what you wanted?
Arnošt Löbel
Autodesk Revit R&D
Thanks for the explanation, I think I get it now. I'll give it a shot.
Hi Patrick,
Were you able to use Arnost's suggestion to read out the current Revit warnings?
hi Arnošt, i tried your suggestion, and it's almost working except that i cannot make retrievd info (i.e. element ids) from failure accessor to do meaningful work, for instance, isolate or even delete some elements, i tried both in failure processing mode and in current command scope
1) in failure processing mode, document changes is prohibited
2) in current command scope, posted command is executed only after the external command completes its execution, so no way to use "future" retrievd info for "present" use, isn't it? any workaround?
see below code snippet for your info
public class Command : IExternalCommand
{
List<ICollection<ElementId>> lst = new List<ICollection<ElementId>>();
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
{
...
app.Application.FailuresProcessing += new EventHandler<FailuresProcessingEventArgs>(FailuresProcessing);
RevitCommandId id = RevitCommandId.LookupPostableCommandId(PostableCommand.ReviewWarnings);
AddInCommandBinding binding = app.CreateAddInCommandBinding(id);
app.PostCommand(id);
TaskDialog.Show("testing", lst.Count.ToString()); // this will always return default value 0
... // do some document changes based on these element ids
return Result.Succeeded;
}
private void FailuresProcessing(object sender, FailuresProcessingEventArgs e)
{
...
}
}