Grasshopper

algorithmic modeling for Rhino

I've a very simple gh file that I think should return the index of an item matching a search item.  But I haven't figured out why I'm always getting a -1 not found result.

 

I have a list of values, and a picklist of values.  I'm using Item Index to match the picklist item to the list of values and I want to get back the index of where the picklist item was found.  Any ideas what I'm doing wrong.

 

Text%20Search.gh

Views: 5730

Replies to This Discussion

Try using the "List item" component.

Again, file is not attached along with post.

Attachments:

Thanks for the quick take on this.  "List Item" works if I know the index of where the string occurs in the list.  But in the case where I don't know the index value ahead of time, I need to be able to do a text search for pick value string in the list of possible values and have the index of where in the list that pick value returns.

 

Note that in my case the specific order of values in the value list are going to be dynamic.  That's why I need to search for the pick value string and have the location index returned. 

 

When I look at the component "Item Index", it sure seems to me that it should work for what I need... I just can't get it to work.  Any more ideas?

I am not sure I understand you.
Is this what you want to achieve:

Attachments:

Yes!  Exactly!  So why doesn't "Item Index" component do the same thing?  Seems to me that "Item Index" should work but just looks for an exact match, while "Find similar member" maybe looks for a "near" match.  Still, doesn't make sense to me that "Item Index" doesn't work with your setup.

BTW, thanks so much @djordie... I don't know that I ever would have tried Find Similar... at least not until my head was bloody from hitting the wall for a long time.

Thanks Chris for pointers on the use of Item Index.  I don't know why I can't find that information when I search the forums... Pilot error I guess.  Anyway, that thread explains why Item Index doesn't work, although I find that is it totally counter intuitive and misleading.  Maybe the component help or component name will be changed in the future to better explain what it does, because it sure sounds like it should work based on the help, name, and especially the way List Item works.  The component really seems like it is a kissing cousin of List Item, but it doesn't work that way.  IMO

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service