[英]Create a collection of item ids Revit API in Python
因此,我嘗試使用輸入字符串列表,使用Revit API在視圖中隔離它們。 我做到了這一點,但我陷入困境,我正在嘗試創建一個集合,該集合接受視圖中的所有元素並刪除從輸入ID創建的元素。 我這樣做最終得到一組所有元素,除了我想要隔離的元素。
dataEnteringNode = IN0
view = IN0
str_ids = IN1
doc = __doc__
collector = FilteredElementCollector(doc, view.Id)
for i in str_ids:
int_id = int(i)
id = ElementId(int_id)
element = doc.GetElement(id)
element_set = ElementSet()
element_set.Insert(element)
elements_to_hide = collector.WhereElementIsNotElementType().Excluding(element_set).ToElements()
#Assign your output to the OUT variable
OUT = elements_to_hide
我非常感謝幫助解決這個錯誤。 我得到了“預期的ICollection [ElementId],得到了設定”。 我猜這個問題出在一個排除過濾器,我需要創建一個要排除的ID集合,但我不知道如何。 先感謝您。 提前感謝您的幫助!
您的代碼不起作用的原因是Revit API中的ElementSet
沒有實現ICollection<T>
接口 - 只是IEnumerable<T>
。 因此, ICollection<T>
代碼正常工作,您需要從集合中創建ICollection<T>
對象。
嘗試這樣的事情:
# ...
from System.Collections.Generic import List
element_collection = List[ElementId](element_set)
elements_to_hide = collector.WhereElementIsNotElementType().Excluding(element_collection).ToElements()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.