How to create an icollection to work with revit api

Hello im having some problems when i’m using icollection to hide elements temporary in views.


it says to me :
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 49, in
File “”, line 44, in Fhide
TypeError: expected ICollection[ElementId], got ElementId

im trying to create an Ilist but it says that:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 38, in
TypeError: Cannot create instances of IList[ElementId] because it is abstract
Thanks for your help

You have done it in line 38.
Try to replace ids with col1 in line 44

Edit: To answer the title of the thread:
A C# ICollection(ElementId) equivalent in python : List[ElementId]

Remember the following reference
clr.AddReference(“System”)
from System.Collections.Generic import List

Example:
col1 = List[ElementId](ids)

1 Like

ids is only the name for reference in function definition when i call the function i pass col1 as argument

Yes, I didn’t read your code very thoroughly. But I think if you use the map function, you iterate over each element Id in the list an therefore end up with picking the ids out of the collection.

Yes i delete return map(Fid,e), really i think i dont need to return anything to hide elements

Im trying it without using map function, only with for loop

1 Like

I mean in line 49, you’ll need one collection for each view

Can i use the same collection for all?

Yes, something like this:
for v in views:
v.HideElementsTemporary(col1)

thank now it works but seems that it activate temporary hide mode but dont hide anything

from where we will get such references

If you are asking how to add in references in python, just copy and paste the reference to the top of a python script (after the clr imports in default python nodes)

Paste this:

clr.AddReference(“System”)
from System.Collections.Generic import List

my doubt is how do we now the python script which is equivalent to C#