Grasshopper

algorithmic modeling for Rhino

When in the input index of List Item component, you give a value of -1 or -2, this component will return the last or penultimate item in the list. When you give a higher index of the size of the list, as list.lenght +1, the component will return the element at index 1 from the list.


Well, I'm trying to reproduce something similar within a VB component, but I not found the underlying logic. Could someone tell me how I have to do?


For example, in a list of 5 items, I want to find the index in the list corresponding to the number 22. It should be 2. If the number is - 14, the index into the list would be 1.


Is there any explicit method for this? or is a code-mathematical operation that can not see?


Thank You.

Views: 521

Replies to This Discussion

Grasshopper.Kernel.GH_MathUtil.WrapInteger.

I need this so often that I made a static method for it in the GH SDK.

Perfect, so easy!

Gracias David :)

Not very useful anymore since David's answer, but anyway - I used to do something like this:

Thanks Pieter!!! that was exactly what I wanted to know. I knew it was something with the Mod operator, but my mind was not too skillful today. ;)

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service