ICollections

Hello ,

when im try use next method : (try create ICollections)

clr.AddReference("System")
from System.Collections.Generic import List
Ids=List[ElementId]()
for i in IN[0]:
	Ids.Add(UnwrapElement(i).Id)

have a next trouble : ElementId is not found
In IN[0] im give pipe insulations or any another elements from revit

whats the problem?

Solution:
Shoud be import Revit API for detect ElementId

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import * #use ElementId
from System.Collections.Generic import * #use LIST

if isinstance(IN[0],list):
	els = UnwrapElement(IN[0])
else:
	els = [UnwrapElement(IN[0])]
	
lst_id = []
lst =[]
for i in UnwrapElement(els):
	lst_id.append(i.Id)
icolls = List[ElementId](lst_id)

OUT = icolls

@erfajo thanks to show me this shortest and easy way)

1 Like