How to create an icollection to work with revit api


#1

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


Workset Editability
#2

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)


View.IsolateElementTemporary Error
Add Point To topo
#3

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


#4

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.


#5

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


#6

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


#7

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


#8

Can i use the same collection for all?


#9

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


#10

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


#11

from where we will get such references


#12

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

#13

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