List of ElementId is empty

I am trying to set up a python script that temporary isolates selected elements. I managed to get the Element Id from RiR’s “Element Passport” component. But when I run my script below, it looks the iCollection doesn’t work. Can someone help me with it? To be honest, I don’t really understand the line “col = ListElementID”. It is beyond my understanding of Python.

import clr
import System
clr.AddReference('System.Core')
clr.AddReference("System")
from System.Collections.Generic import *
clr.AddReference('RhinoInside.Revit')
clr.AddReference('RevitAPI') 
clr.AddReference('RevitAPIUI')
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System import Enum
import rhinoscriptsyntax as rs
import Rhino
import RhinoInside
import Grasshopper
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
from RhinoInside.Revit import Revit, Convert
from Autodesk.Revit import DB
from Autodesk.Revit.DB import *
doc = Revit.ActiveDBDocument
if z:
    t = DB.Transaction(doc, "Set Temporary Views")
    t.Start()
    try:
        col1 = List[ElementId](y)
        print (col1)
        x.IsolateElementsTemporary(col1)
        t.Commit()
    except Exception as txn_err:
        print(txn_err)
        t.RollBack()

Make sure the y input is set to receive a list (in type hinting) or try List[ElementId]([y]) instead (create a list from input y using [y])

Hi Ehsan, thank you for the suggestion. But the ListElementId is in the script and it is not working. What is the meaning of the line? “ListElementId the python node returns an error saying ElementId is not defined.

I changed the y input to element itself and get element id inside the node, then it worked.

doc = Revit.ActiveDBDocument

if bool:
t = DB.Transaction(doc, “Set Temporary Views”)
t.Start()
try:
ids =
for i in elemts:
ids.append(i.Id)
col1 = ListElementId
view.IsolateElementsTemporary(col1)
t.Commit()
except Exception as txn_err:
print(txn_err)
t.RollBack()

If that is the error then try List[DB.ElementId]. Element Id is part of Autodesk.Revit.DB namespace.

As for its meaning, List[DB.ElementId]() is equivalent to List<DB.ElementId>() in C#. It creates a list that can only contain instances of DB.ElementId

1 Like