修改命名空间
This commit is contained in:
37
ShrlAlgoToolkit.RevitCore/Assists/DwgElementSelection.cs
Normal file
37
ShrlAlgoToolkit.RevitCore/Assists/DwgElementSelection.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitCore.Assists;
|
||||
|
||||
/// <summary>
|
||||
/// <c>
|
||||
/// dwg元素选择过滤,ObjectType.PointOnElement,默认选择块,选择曲线使用 ElementReferenceType.REFERENCE_TYPE_LINEAR
|
||||
/// var dwgElemSelection = new DwgElementSelection(ElementReferenceType.REFERENCE_TYPE_LINEAR);
|
||||
/// var refer = UiDocument.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.PointOnElement, dwgElemSelection);
|
||||
/// Element elem = Document.GetElement(refer);
|
||||
/// GeometryElement geoElem = elem.get_Geometry(new Options());
|
||||
/// GeometryObject geoObj = elem.GetGeometryObjectFromReference(refer);
|
||||
/// 图层:(Document.GetElement(geoObj.GraphicsStyleId) as GraphicsStyle).GraphicsStyleCategory.Name
|
||||
/// 元素类型:geoObj?.GetType().Name
|
||||
/// </c>
|
||||
/// </summary>
|
||||
public class DwgElementSelection : ISelectionFilter
|
||||
{
|
||||
private readonly ElementReferenceType elementReferenceType;
|
||||
private Element e;
|
||||
public GeometryObject SelectedElement { get; private set; }
|
||||
public DwgElementSelection(ElementReferenceType elementReferenceType = ElementReferenceType.REFERENCE_TYPE_INSTANCE)
|
||||
{ this.elementReferenceType = elementReferenceType; }
|
||||
|
||||
public bool AllowElement(Element elem)
|
||||
{
|
||||
e = elem;
|
||||
return e.Document.GetElement(e.GetTypeId()) is CADLinkType;
|
||||
}
|
||||
|
||||
public bool AllowReference(Reference reference, XYZ position)
|
||||
{
|
||||
return reference.ElementReferenceType == elementReferenceType &&
|
||||
e.GetGeometryObjectFromReference(reference).GraphicsStyleId != ElementId.InvalidElementId;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user