📌  相关文章
📜  获取选定的元素 dynamo revit - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:17.689000             🧑  作者: Mango

代码示例1
import clr

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from System.Collections.Generic import List

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

def tolist(obj1):
    if hasattr(obj1,'__iter__'): return obj1
    else: return [obj1]

def flatten(x):
    result = []
    for el in x:
        if hasattr(el, "__iter__") and not isinstance(el, basestring):
            result.extend(flatten(el))
        else:
            result.append(el)
    return result

elements = UnwrapElement(flatten(tolist(IN[0])))

selected = []
Icollection = List[ElementId]()
for e in elements:
    try:
        Icollection.Add(e.Id)
        selected.append(e)
    except:
        pass
DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument.Selection.SetElementIds(Icollection)

OUT = selected