For & If statment

Hi
I am trying to get the ID for a element that har has the same marks so I can get the subcomponents of them.
But I cant filter out all the marks with nr 1, 2,3 ect
As you see the loop for with if dose seem to work.
But when I tried the same thing se below with
[1,2,3,4] and [20,30,40,50] it dose

please someone help me

The value of your “Mark” parameter is most likely a string, causing the comparison to not work as expected. Instead, you can write something like this:

marks = IN[0]
ids = IN[1]

ids_filtered = []
for mark, id in zip(marks, ids):
    if int(mark) >= 3:
        ids_filtered.append(id)

OUT = ids_filtered

I have absolutely no idea why you code works for the list with Id’s, but not the [1,2,3,4] and [20,30,40,50]. I tried it myself and everything works fine. Have you ran the script after you changed things?

Why did you chose for Python on this problem and not OOTB Dynamo nodes?

To add to what @cgartland said, the Element ID in Revit is it’s own class, not a number. As such you would need to convert it to a string or number and do a like for like comparison :slight_smile:

1 Like