32 lines
835 B
C#
32 lines
835 B
C#
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.UI.Selection;
|
|
|
|
namespace SZMCToolkit.RevitAddins.Assists;
|
|
|
|
/// <summary>
|
|
/// dwg块选择过滤
|
|
/// </summary>
|
|
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;
|
|
}
|
|
} |