Having trouble with the Item Index component and its driving me nuts

Sorry if this comes across a beginner question.
What I’m working on is unimportant, but the gist of it is that I need to detect the point on a brep with the lowest Z value. I am deconstructing the brep into points, extracting the Z component, sorting it, then finding the index of the lowest value in order to use that to cull the list and just spit out the point with the lowest Z component. Pretty simple.

As you can however see, the Item Index component is not finding the value of 9.4 in the list. I’m 100% certain that this should not be happening and that I used the component correctly?

Is this a bug, or am I just dumb? Thanks

Dont Go thru the panel. Go directly.

1 Like

Item Index is a tricksy thing. It’s not what you think it is: Find The Index of This Value. Instead it’s much more specific: Find The Index of This Specific Data. Not any Number that equals 9.4, but the actual instance of the Number data type in memory. It’s got quite limited usefulness.

To get the lowest point, use the Sort list component as you already have it, but pipe the Vertices through the Values input and take the zeroth item (or -1 for the highest point). This operation is “sort list 1, then put list 2 in the same order”

1 Like

sorry, should have been clearer in the image. the item index component isn’t actually connected to the panel, it just looks that way because its layered over. if you look closer then you can see where the left hand wire is thicker than the right hand one.

Thanks Tom,
I got it to work by just using cull pattern instead.


much appreciated

Effectively the same :slight_smile:
(although probably marginally less performant if you’re sorting a LOT of points)

PS: You can use Member Index to actually search for a value in a list, but it’s not a robust solution because it can get confused by duplicates, and only handles simple data types (booleans, integers, numbers, strings, points, vectors, maybe one or two more I can’t recall right now!)

You could have posted code, as recommended, to avoid confusion.

3. Attach minimal versions of all the relevant files

(post deleted by author)

Is there a reason you cannot feed the indices into the value and sort the points?

1 Like

For science. This might shed some light into the component:

item index V1.gh (29.2 KB)

Not sure I followed, but like this?

Sort V1.gh (25.1 KB)

Technically seen its a bug. Although its an inefficient approach, I would not assume a failure here.
I don’t think this is the actual problem. I think its based on a function like “FindIndex”. Value types are special, and it would surprise me if it looks for an instance handle/ptr and not for the actual value.
I think the problem is rather somehow related to the “Sort” component. I could imagine that there is a implicit type conversion when piping it to the key input. Maybe because its the key, it converts the keys to strings and then sorts them (maybe even parsing it to double back-and-forth) and yielding a string as an output. In most cases, keys are assumed to be strings…

But it does, in my experience.

I read the problem as you want to find the point in a list that has the minimum Z component. (Now Y). The rest of your discussion is of no meaning since none of us have any clue about the overall problem. Stamps yadda yadda means nothing.

If that is indeed the problem, you can sort the points using a key. After sorting the minimum point will always be index 0. If your brep will ever have coordinates with the same y or z value, you will need more logic to find the point needed. Deconstructing a brep does not always result in the order you might expect.

I do not follow your problem after opening the script. If you have the outline shape earlier in the script why are you working with the modified shape? If there is some reason, you can use the untrim component to find the outline. That does not work in all cases, but here it did.

By your reply and multiple edits I realized that you are at a level that you´re not worth my time, no offense. People with more patience will chime in.