2

So I am trying to use a list of input strings to isolate them in a view using Revit API. I got this far, but I am getting stuck where I am trying to create a set that takes all elements in a view and removes ones that are created from input IDs. I am doing this to end up with a set of all elements except ones that i want to isolate.

dataEnteringNode = IN0
view = IN0
str_ids = IN1
doc = __doc__
collector = FilteredElementCollector(doc, view.Id)

for i in str_ids:
    int_id = int(i)
    id = ElementId(int_id)
    element = doc.GetElement(id)
    element_set = ElementSet()
    element_set.Insert(element)

elements_to_hide = collector.WhereElementIsNotElementType().Excluding(element_set).ToElements()

#Assign your output to the OUT variable
OUT = elements_to_hide

I would greatly appreciate a help in solving this error. I am getting that "expected ICollection[ElementId], got set". I am guessing the problem lies in a Excluding filter where i need to create a collection of Ids to exclude but I dont know how. Thank you in advance. Thank you for help in advance!

1
  • Which line caused the error? And I think element_set should be declared outside the loop, not inside. Commented May 26, 2014 at 7:34

1 Answer 1

4

The reason your code doesn't work is that ElementSet in the Revit API does not implement the ICollection<T> interface - just the IEnumerable<T>. So, to get your code working, you will need to create an ICollection<T> object from your set.

Try something like this:

# ...
from System.Collections.Generic import List
element_collection = List[ElementId](element_set)
elements_to_hide = collector.WhereElementIsNotElementType().Excluding(element_collection).ToElements()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.