VerPipeFilter.cs 935 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using Autodesk.Revit.DB;
  3. using Autodesk.Revit.DB.Plumbing;
  4. using Autodesk.Revit.UI.Selection;
  5. using SAGA.RevitUtils.Extends;
  6. namespace SAGA.RevitUtils.MEP
  7. {
  8. public class VerPipeFilter : ISelectionFilter
  9. {
  10. public bool AllowElement(Element elem)
  11. {
  12. bool flag = false;
  13. if (elem.GetCategory() != BuiltInCategory.OST_PipeCurves)
  14. {
  15. return flag;
  16. }
  17. Pipe pipe = elem as Pipe;
  18. if (pipe == null)
  19. {
  20. return flag;
  21. }
  22. Line curve = pipe.Location.GetLine();
  23. return (curve.StartPoint().NewZ(0.0).IsEqual2(curve.EndPoint().NewZ(0.0), 0.0) && (Math.Abs((double) (curve.StartPoint().Z - curve.EndPoint().Z)).FromApi() >= -1.0));
  24. }
  25. public bool AllowReference(Reference reference, XYZ position)
  26. {
  27. return true;
  28. }
  29. }
  30. }