Failiurehandling

Failiurehandling

dante.van.wettum
Advocate Advocate
413 Views
1 Reply
Message 1 of 2

Failiurehandling

dante.van.wettum
Advocate
Advocate

 

What i am trying to do is edit the mark value in bulk.

This works well, though i need to catch the "Duplicate mark" error so i dont get any duplicates.

 

What i try do do, is assign the parameter, and check if it is generating an error:

 

......<custom class FailureHandler : IFailuresPreprocessor> .....
<snip-it>

if (ErrorMessage == "Elements have duplicate \"Mark\" values.") { return FailureProcessingResult.ProceedWithRollBack; }

so in my actual transaction:

 

Transaction tr = new Transaction(doc);
//Overwrite failiure handling FailureHandlingOptions fHO = tr.GetFailureHandlingOptions(); FailureHandler fH = new FailureHandler(); fHO.SetFailuresPreprocessor(fH); fHO.SetClearAfterRollback(true); tr.SetFailureHandlingOptions(fHO); transGroup.Start("Do My Thing"); foreach (Tuple<ElementId, string> tup in ids) { using (tr) { var transStatus = tr.Start("sub-step"); try { Element el = doc.GetElement(tup.Item1); Parameter p = el.get_Parameter(BuiltInParameter.ALL_MODEL_MARK); p.Set(tup.Item2); } catch (Exception ex) { TaskDialog.Show("DEBUG", ex.Message); } tr.Commit(); } } transGroup.Assimilate();

now what i want to do, is check if this error occurs when trying to add the mark, if it happens, edit the mark (something like an int counter ++ toString) and try it again. Keep trying this untill it works.

With the above code, i think i am almost there, only i dont know the last part where i check and retry when doing the transaction.

any thoughts/ last push ?

 

 

 

0 Likes
Accepted solutions (1)
414 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Dante,

 

Thank you for your query.

 

This is covered by the Revit Failure API:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.32

 

Several quite complex failure API issues have been discussed and solved quite recently here in the forum as well.

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder