24 lines
690 B
C#
24 lines
690 B
C#
|
|
using Autodesk.Revit.DB;
|
|||
|
|
using Autodesk.Revit.UI.Selection;
|
|||
|
|
|
|||
|
|
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 任意选择过滤器
|
|||
|
|
/// </summary>
|
|||
|
|
public class FuncFilter(Func<Element, bool> allowElement, Func<Reference, XYZ, bool> allowReference = null)
|
|||
|
|
: ISelectionFilter
|
|||
|
|
{
|
|||
|
|
private readonly Func<Element, bool> elementFunc = allowElement;
|
|||
|
|
private readonly Func<Reference, XYZ, bool> referenceFunc = allowReference;
|
|||
|
|
|
|||
|
|
public bool AllowElement(Element elem)
|
|||
|
|
{
|
|||
|
|
return elementFunc(elem);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool AllowReference(Reference reference, XYZ position)
|
|||
|
|
{
|
|||
|
|
return referenceFunc == null || referenceFunc(reference, position);
|
|||
|
|
}
|
|||
|
|
}
|