using Autodesk.Revit.DB; using Autodesk.Revit.UI.Selection; namespace SZMCToolkit.RevitAddins.Assists; /// /// dwg块选择过滤 /// public class DwgBlockSelection : ISelectionFilter { private Element e; public bool AllowElement(Element elem) { e = elem; return e.Document.GetElement(e.GetTypeId()) is CADLinkType; } public bool AllowReference(Reference reference, XYZ position) { //块 var instance = e.GetGeometryObjectFromReference(reference) as GeometryInstance; if (instance == null) { return false; } return reference.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_INSTANCE && instance.GraphicsStyleId != ElementId.InvalidElementId; } }