import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
#Preparing input from dynamo to revit
elements = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
ActiveView = FilteredElementCollector(doc,doc.view.Id)
isoElems = []
for items in elements:
isoElems.append(items.Id)
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
view.IsolateElementsTemporary(isoElems)
TransactionManager.Instance.TransactionTaskDone()
OUT = "Done!"
A list is a pure Python Object, a ICollection is a .Net object (embedded by IronPython in your case), and IsolateElementsTemporary need a .Net Collection
try this
isoElems = List[ElementId]()
for item in elements:
isoElems.Add(item.Id)
import sys
import clr
sys.path.append(r'C:\\Program Files (x86)\\IronPython 2.7\\Lib')
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
#Preparing input from dynamo to revit
elements = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
ActiveView = FilteredElementCollector(doc,view.Id)
isoElems = List[ElementId]()
for item in elements:
isoElems.Add(item.Id)
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
view.IsolateElementsTemporary(isoElems)
TransactionManager.Instance.TransactionTaskDone()
OUT = "Done!"