12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using Autodesk.Revit.DB;
- using Autodesk.Revit.DB.Plumbing;
- using Autodesk.Revit.UI.Selection;
- using SAGA.RevitUtils.Extends;
- namespace SAGA.RevitUtils.MEP
- {
- public class PipeFilter : ISelectionFilter
- {
- private Predicate<Pipe> m_Predicate;
- private PipeSystemType m_Pst;
- private Func<Reference, XYZ, bool> m_ReferenceFunc;
- public PipeFilter(PipeSystemType pst = 0, Predicate<Pipe> conduit = null, Func<Reference, XYZ, bool> referenceFunc = null)
- {
- this.m_Pst = pst;
- this.m_Predicate = conduit;
- this.m_ReferenceFunc = referenceFunc;
- }
- public bool AllowElement(Element elem)
- {
- if (!(elem is Pipe))
- {
- return false;
- }
- bool flag = true;
- Pipe pipe = (Pipe) elem;
- if (this.m_Pst != PipeSystemType.UndefinedSystemType)
- {
- flag = pipe.GetPipeSystemType() == this.m_Pst;
- }
- bool flag2 = elem.GetCategory() == BuiltInCategory.OST_PipeCurves;
- if (this.m_Predicate != null)
- {
- flag = flag && this.m_Predicate(pipe);
- }
- return (flag && flag2);
- }
- public bool AllowReference(Reference reference, XYZ position)
- {
- if (this.m_ReferenceFunc != null)
- {
- return this.m_ReferenceFunc.Invoke(reference, position);
- }
- return true;
- }
- }
- }
|