List.IndexOf node → -1 result, not constantly while input is the same

Hello all,

We are using a graph to write keynotes to the comments parameter of ducts that we have modeled in our project.
(the graph was made with help from the forum, link to the original post)

This was working fine for us, but now we noticed a problem with the round ducts of which we cannot say with certainty if the problem was already there from the beginning. The graph works as follows. Ducts in the model are filtered / grouped by shape.

Next we collect the information from our excel file, diameter + keynote and both go into a list.

Diameters in the excel and Revit model are compared which results in the corresponding keynote.
However, 6 out of the 16 diameters give a -1 result in the List.IndexOf node. So there is no return of keynote to the parameter in revit for those 6 ducts.

Can someone explain why those 6 diameters give a -1 result int the List.IndexOf node? and help us further on the way …
We have already swapped the position of the ø 25mm in the excel list with the 160mm line, but the result stays the same.

Diameters that give the -1 result are; 125mm, 250mm, 355mm, 450mm, 500mm and 1000mm.
Underneath the full graph, the problem only situates with the round ducts, upper parts of the graph (first 2 input groups).
There are no oval or rectangular ducts in the added revit file, hence the exclamation marks, input of a no existing group …

Link to the Revit file + Graph + Excel file, available untill 20 january.

Thanks by advance,
Kind regards,

@Tim0
to your first pic

group[0][1] #🔱list depth

you have to go deeper

Tested, then he only selects one duct instead of 32 ducts that are modeled.

Check the object types (Object.Type) of both lists. I’d guess that some of your numbers are doubles and some are integers. If that’s the case, you can use Math.Floor to convert your doubles to integers.

3 Likes

Hey Nick,

I checked, both lists exist entirely out of system.doubles, no variation between doubles and integers.
Didn’t know the 2 nodes you mention, thanks for pointing out those :wink:

To fast to reply, I’ve put the math floor between both lists and now it works perfectly.
So I need to sent integers instead of system.doubles.

Thanks Nick! :pray:

When working with doubles you often get the display value of 125 instead of 124.9999999999. Any Math.Round method should resolve this. You could also use an == node and a first index of true, dictionary look up (what I would likely do), or other means for finding the correct value after mapping.

1 Like