Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Handel Failure

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Moustafa_K
689 Views, 2 Replies

Handel Failure

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

 Capture.PNG

 


-----------------------------------------------------
Moustafa Khalil
Tags (1)
2 REPLIES 2
Message 2 of 3
Moustafa_K
in reply to: Moustafa_K

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}");

                }
            }

            
        }

 


-----------------------------------------------------
Moustafa Khalil
Message 3 of 3
payalorna
in reply to: Moustafa_K

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;
}

}
}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community