44 lines
1.0 KiB
C#
44 lines
1.0 KiB
C#
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
|
|
|
/// <summary>
|
|
/// 获取当前模型或链接模型的实体元素
|
|
/// </summary>
|
|
public class ElementInLinkOrCurrentDocument : ISelectionFilter
|
|
{
|
|
public ElementInLinkOrCurrentDocument(Document doc)
|
|
{
|
|
this.doc = doc;
|
|
}
|
|
|
|
private readonly Document doc;
|
|
|
|
public bool LastCheckedWasFromLink => null != LinkedDocument;
|
|
|
|
public Document LinkedDocument { get; private set; }
|
|
|
|
public bool AllowElement(Element e)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public bool AllowReference(Reference r, XYZ p)
|
|
{
|
|
LinkedDocument = null;
|
|
|
|
var e = doc.GetElement(r);
|
|
|
|
if (e is RevitLinkInstance li)
|
|
{
|
|
LinkedDocument = li.GetLinkDocument();
|
|
|
|
e = LinkedDocument.GetElement(r.LinkedElementId);
|
|
}
|
|
|
|
return e != null
|
|
&& e.CanHaveTypeAssigned()
|
|
&& e.HasPhases()
|
|
&& e.get_BoundingBox(null) != null
|
|
&& e.Category is { Parent: null }
|
|
&& e is not Panel;
|
|
}
|
|
} |