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