整理代码
This commit is contained in:
51
ShrlAlgo.Toolkit.Revit/Helpers/DwgBlockSelection.cs
Normal file
51
ShrlAlgo.Toolkit.Revit/Helpers/DwgBlockSelection.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <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;
|
||||
}
|
||||
////dwg
|
||||
//foreach (var dwgIns in e.get_Geometry(new Options()))
|
||||
//{
|
||||
// if (dwgIns is not GeometryInstance item) continue;
|
||||
// //遍历dwg包含的所有内容
|
||||
// foreach (var obj in item.SymbolGeometry)
|
||||
// {
|
||||
// return obj is GeometryInstance ins && !ins.SymbolGeometry.Any();
|
||||
// }
|
||||
//}
|
||||
|
||||
//if (selectBlock == null)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
//块是否包含子块
|
||||
//foreach (var item in instance.SymbolGeometry)
|
||||
//{
|
||||
// if (item is GeometryInstance)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
//var isNest = selectBlock.SymbolGeometry.OfType<GeometryInstance>().Any();
|
||||
return /*!isNest &&*/ reference.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_INSTANCE
|
||||
&& instance.GraphicsStyleId != ElementId.InvalidElementId;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user