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: 

supressing warning pop ups

1 REPLY 1
SOLVED
Reply
Message 1 of 2
NemKumar
3237 Views, 1 Reply

supressing warning pop ups

Hi All,

 

I am trying to display a cylinder triangulation by modelCurve(line).

When each model curve is created and rendered, I get very annoying

warning popups saying "line is slightly off the axis........".

 

Here is the code for calculating normal

 

public static SketchPlane createSketchPlane(Document inDoc, Curve inCurve)
{
      Plane plane;

      // Linear curves have no "normal" returned by compute derivatives
      if (inCurve is Line)
      { 
            XYZ point1 = inCurve.GetEndPoint(0);
            XYZ point2 = inCurve.GetEndPoint(1);
            XYZ tangent = (point2 - point1).Normalize();
            // Vertical line
            if (tangent.IsAlmostEqualTo(XYZ.BasisZ) || tangent.IsAlmostEqualTo(-XYZ.BasisZ))
            {
                   plane = inDoc.Application.Create.NewPlane(XYZ.BasisX, point1);
            }
            // Non-vertical line, use cross product with vertical to generate normal vector
            else
            { 
                   XYZ yVector = tangent.CrossProduct(XYZ.BasisZ).Normalize();
                   plane = inDoc.Application.Create.NewPlane(tangent, yVector, point1);
            }
       }
       // Non-linear curve supplies normal for sketch plane
       else
      {
             XYZ point = inCurve.Evaluate(0, true);
             Transform transform = inCurve.ComputeDerivatives(0, true);
             XYZ normal = transform.BasisZ;
             plane = inDoc.Application.Create.NewPlane(normal, point);
       }

       return inDoc.Create.NewSketchPlane(plane);
}

 

Also I tried to suppress warning by using this class

 

public class WarningSwallower : IFailuresPreprocessor
{
        public FailureProcessingResult PreprocessFailures(FailuresAccessor a)
        {
                // inside event handler, get all warnings

               IList<FailureMessageAccessor> failures = a.GetFailureMessages();

               foreach (FailureMessageAccessor f in failures)
               { 
                     FailureDefinitionId id = f.GetFailureDefinitionId();
                     if (BuiltInFailures.RoomFailures.RoomNotEnclosed == id)
                     a.DeleteWarning(f);
                }
                return FailureProcessingResult.Continue;
          }
}

 

and use this class as in 

 

public static void setFailureDialogSuppressor(Transaction tranasaction)
{
         FailureHandlingOptions failOpt = tranasaction.GetFailureHandlingOptions();
         failOpt.SetFailuresPreprocessor(new WarningSwallower());
         tranasaction.SetFailureHandlingOptions(failOpt);
}

 

and i make call it after

 

using (Transaction trans = new Transaction(mRevitDoc.Document))
{
       trans.Start("create Triangles");
       CFRevitGraphicsUtility.setFailureDialogSuppressor(trans);

       .....

       trans.Commit()

}

 

I need to fix this urgently as I dont have much time left.

I am not able to figure out what am I missing or doing wrong.

 

As I am creating 100s of cylinders, it popsup for 100s of times.

I dont know how to disable or suppress it.

OR fix the warning itself.

 

solution for either of the problem will be helpful.

 

Thanks in Advance.

Tags (1)
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: NemKumar

And what If you change your warning swallower to :

 

public FailureProcessingResult PreprocessFailures(FailuresAccessor a)
{
IList<FailureMessageAccessor> failures = a.GetFailureMessages();

foreach (FailureMessageAccessor f in failures)
{
FailureDefinitionId id = f.GetFailureDefinitionId();

FailureSeverity failureSeverity = a.GetSeverity();

if (failureSeverity == FailureSeverity.Warning)   //simply catch all warnings, so you don't have to find out what warning is causing the message to pop up
{
a.DeleteWarning(f);
}
else
{
return FailureProcessingResult.ProceedWithRollBack;
}
}
return FailureProcessingResult.Continue;
}

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community