Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 66677

Re: Add-in Command invokes revit to request user relinquish worksets, could be m

$
0
0

I come across this scenario quite often:

 

using (Transaction t = new Transaction(doc, tName))
            {
                FailureHandlingOptions foptions = t.GetFailureHandlingOptions();
                FailureHandler fhandler = new FailureHandler();
                foptions.SetFailuresPreprocessor(fhandler);
                foptions.SetClearAfterRollback(true);
                t.SetFailureHandlingOptions(foptions);
                t.Start();

                foreach (Element element in elements)
                {
                 //do something here...
                 //90% of elements are cool, 
                 //5% generate Warnings, which we can swallow
                 //3% generate Errors, which we can solve, but
                 //2% will generate errors that we just want to SKIP over!!!
                }
            }

We are inside a single transaction, iterating over many elements. Most of them will be fine, some will generate Warnings, which we can suppress, but a few will generate Errors, which we can either resolve, but - which is in the case of someone owning a Workset that the element is in - we can't do a thing. 

 

My question is - what options do we have? The only thing that I can come up with is to have 2 loops - one test run to get the elementIds which are causing the errors from withing the FailureHandler and somehow pass them back to the main method, then exclude those elements from the second run. But that just feels wrong and backwards - is there a more elegant and .. right way to tackle this issue?


Viewing all articles
Browse latest Browse all 66677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>