Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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 ?
Solved! Go to Solution.