Does handle Failure remove all failures or there are some not?
I have implemented the next event handler Code to resolve all errors but unfortunatly it skipped the one see attached image.
to cut a long story short: i written a plugin to update all revit fies to Revit2015. when it comes to certain files that miss information such the attached image it stops and awaits users input, which would be normall to close.
any clues
the Code
#region IFailuresPreprocessor Members public string errorMessage { set; get; } public string errorSeverity { set; get; } private void OnFailuresProcessing( object sender, FailuresProcessingEventArgs e) { FailuresAccessor failuresAccessor = e.GetFailuresAccessor(); IList<FailureMessageAccessor> faillist = new List<FailureMessageAccessor>(); //inside event handler get all warrnings faillist = failuresAccessor.GetFailureMessages(); foreach (FailureMessageAccessor failureMes in faillist) { FailureDefinitionId fid = failureMes.GetFailureDefinitionId(); try { errorMessage = failureMes.GetDescriptionText(); } catch (Exception) { errorMessage = "Unknown Error"; } try { FailureSeverity fsav = failureMes.GetSeverity(); errorSeverity = fsav.ToString(); if (fsav == FailureSeverity.Warning) { failuresAccessor.DeleteWarning(failureMes); } else { failuresAccessor.ResolveFailure(failureMes); e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit); return; } } catch { try { e.SetProcessingResult(FailureProcessingResult.ProceedWithRollBack); } catch { Util.MsgInfo("Failed all, will try closing document"); failuresAccessor.GetDocument().Close(false); } } } e.SetProcessingResult(FailureProcessingResult.Continue); return; } #endregion
Solved! Go to Solution.
Solved by Moustafa_K. Go to Solution.
Hi
Finally i resolved the problem through threading i have imlemented this code by applying another thread and sending the ESC key.
public static void killdialog() { Thread dlgWatcher = new Thread(ClosePopupWindow); dlgWatcher.IsBackground = true; // dlgWatcher.SetApartmentState(ApartmentState.STA); dlgWatcher.Start(); } [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName); public static void ClosePopupWindow() { while (Command.closethread != true) { Thread.Sleep(1000); IntPtr dialog = FindWindowByCaption(IntPtr.Zero, "Upgrade Project"); if (dialog != IntPtr.Zero) { SetForegroundWindow(dialog); SendKeys.SendWait("{ESC}"); } } }
When I Join Structural Column and Floor it give me failure that Can't cut join element.
What should I do for neglecting that Structural Column and Floor and how to handel this failure?
I am using this code for join:
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace JoinGeometry
{
[Transaction(TransactionMode.Manual)]
class CFjoin
{
bool check;
public Result Execute(ExternalCommandData commandData)
{
UIApplication uiApp = commandData.Application;
UIDocument uidoc = uiApp.ActiveUIDocument;
Document doc = uidoc.Document;
using (Transaction t = new Transaction(doc, "Join All Walls/Floors"))
{
t.Start();
FilteredElementCollector col = new FilteredElementCollector(doc, doc.ActiveView.Id);
col.OfClass(typeof(FamilyInstance));
col.OfCategory(BuiltInCategory.OST_StructuralColumns);
foreach (FamilyInstance column in col)
{
// get the bounding box of this wall
// BoundingBoxXYZ bbox = column.get_BoundingBox(null);
// create an outline from the min and max points of the bounding box
// Outline outline = new Outline(bbox.Min, bbox.Max);
// find all floors that intersect the wall
foreach (Element floor in new FilteredElementCollector(doc)
.OfClass(typeof(Floor))
.WherePasses(new ElementIntersectsElementFilter(column)))
{
check = JoinGeometryUtils.AreElementsJoined(doc, column, floor);
if(check==true)
{
}
else
{
JoinGeometryUtils.JoinGeometry(doc, column, floor);
JoinGeometryUtils.SwitchJoinOrder(doc, column, floor);
}
}
}
t.Commit();
}
return Result.Succeeded;
}
}
}