Get Index value of input

Hi,

Just a silly question, how to get index value from Item Access input in c# script?

How about:

List listObj = new List();

int idx = listObj.IndexOf(obj);

or

int index = myList.FindIndex(a => a.Prop == oProp);

Cheers

I am quite new in using Data Tree, i was trying to list individual curve from an array, how do I display each curve on every curve array from DataTree<Curve> dt = new DataTree<Curve>();?

The question is if you really need DataTree. Why not using a simple List?. In your example you have a really simple (flat) DataTree. It looks more like a list.

Hi,
I tried using list now, but i still can’t see the individual curves. How do i see the individual object?
List<Curve> dt = new List<Curve>();
image

In your first post you want to get the index. This can be done with
int idx = yourList.IndexOf(yourCurve);

In your last post you want to get the curve at index. This can be done with
var crv = yourList[i];

With DataTree should look like this:

foreach(GH_Path myPath in test.Paths)
{
foreach(object obj in test.Branch(path))
{
// here obj = your curve
}
}

1 Like

Got it, Thanks