DataTree.Item property missing?

Hello all,

I am trying to replace a specific item in a tree with the C# component in GH and I can’t seem to get access to the DataTree.Item property - all the other properties are accessible except for Item.

I noticed there seems to be an error on the Grasshopper API for this property?

I tried just typing it according to the API anyway and I got an error that there is no definition for it.

Is there a better way to replace a specific item in a tree - am I just being dense here?

I’ve attached a test code to recreate the issue here:

int pathIndex = 0;
DataTree pts = new DataTree();

for (int i = 0; i < 10; i++)
  GH_Path path = new GH_Path(pathIndex);
  for (int j = 0; j < 5; j++)
    Point3d pt = new Point3d(j, i, 0);
    pts.Add(pt, path);
  pathIndex += 1;

pts.Item(0, 2) = new Point3d(5, 5, 0);
A = pts;

Many thanks,


1 Like

You can do this by pts.Branch(0)[2]=…

For gh structure you can use pts[0][2], but I am not sure if this works in datatrees as well or probably it should work because item stands for indexing not method:

Try to use pts[0,2]=

1 Like

Nice, thank you,

The second option works as long as you supply a GH_Path for the first argument

So pts[new GH_Path(0),2] throws up no issues.

Thanks a lot!

1 Like