IndexOf not working

Hi, why is this not working? I can’t figure out why the node IndexOf returns -1 for value at index 32. It should return 59 instead. All the others values are fine. Does anyone have an idea what is wrong?

Here the whole script

Any chance there is an extra space after the number in one of the parameter values?

1 Like

I checked that already, no extra spaces :frowning: I have also deleted (for a test) the area and sheet from revit which correspond to value at index 32, but it didn’t helpe. After deleting, value at index 32 corresponds to other Area and Sheet but still have the issue and returns value -1
And when I swap connections the IndexOf works perfectly, no warnings… but that’s not what I need…

Is there any other node working similar like IndexOf so I can work around?

With string comparison the issue is often that the true values aren’t what we read them to be, with hidden characters and the like causing issues.

Since all the values are numbers, but are stored as strings, try converting them to numbers (String.ToNumber) and see if that gets a consistent comparison result.

1 Like

Still not working :frowning:

Does it work with list all indicies of ?

I’m confused by the highlighting - GetItemByIndex and List.IndexOf should have the same list number highlighted here.

What is list item 32 in the GetItemByIndex? Does that value exist in your watch list?

Simplified comparison. In this case I’m checking to see if “3” exists in the list. Since it doesn’t, it returns as -1.


@Robert_Younger you were right, thanks a lot! One of my Areas had duplicated number and I caused an issue.