Hi Jeremy, thank you very much for the very thorough answer, however, I believe you may not have quite understood my question (or maybe I'm misunderstanding your answer!).
I wasn't confused about how to pass data around or return data in general, but specifically to the Failure Processing stage of a Revit transaction.
As far as I can tell the general stage for this process is as follow:
* Addin creates a transaction
* Addin calls Transaction.Commit() to end the transaction
* The failure preprocessor is executed.
* Failure processing event is flagged and all failure processing event handlers are run
* Failure processor is run
* The transaction is now finally either committed or rollbacked by revit.
* The addin will now execute the line of code that comes after Transaction.Commit().
My issue is that I want Revit to continue with its standard failure processing, but I just want the information about those failures. From the perspective of my Add-In I can call a transaction and pass it a custom preprocessor class, however, this doesn't appear to be a real object, just a method that gets run with a set return value. I could also hook up a preprocessor event handler, but again, there's no simple way to get information from my event handler, back into my main program.
Here's the preprocessor example from the ErrorHandling SDK sample:
Transaction transaction = new Transaction(m_doc, Warning_FailurePreproccessor_OverlappedWall");
FailureHandlingOptions options = transaction.GetFailureHandlingOptions();
FailurePreproccessor preproccessor = new FailurePreproccessor();
options.SetFailuresPreprocessor(preproccessor);
transaction.SetFailureHandlingOptions(options);
transaction.Start();
Line line = Line.CreateBound(new XYZ(-10, 0, 0), new XYZ(-20, 0, 0));
Wall wall1 = Wall.Create(m_doc, line, level1.Id, false);
Wall wall2 = Wall.Create(m_doc, line, level1.Id, false);
m_doc.Regenerate();
transaction.Commit();
So I can pass in a preprocessor object to handle the preprocessing where I can access the failure errors. However the preprocessor object just looks like this:
/// <summary>
/// Implements the interface IFailuresPreprocessor
/// </summary>
public class FailurePreproccessor : IFailuresPreprocessor
{
/// <summary>
/// This method is called when there have been failures found at the end of a transaction and Revit is about to start processing them.
/// </summary>
/// <param name="failuresAccessor">The Interface class that provides access to the failure information. </param>
/// <returns></returns>
public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
{
}
}
With just a single method (PreprocessFailures) that presumably gets called by Revit, with a set return value to Revit. So my issue is here, how do I get information from this failure preprocessing method, back into my main program? The preprocessor's return value gets returned to Revit, not my addin, and if I want to implement the IFailuresPreprocessor interface I can't pass in a ref or out variable to the preprocessor to write to as far as I can tell.