Grasshopper

algorithmic modeling for Rhino

Hi all
just one simple question. How to read DataTree in C# component (GH 0.7.30). Exist some simple example for that? When i try something like this ...  i get some part from input, but im not sure if is it correct way how to make it.

private void RunScript(Curve geom, Plane plnA, Plane plnB, ref object A)
  {
    //your code here…
    DataTree<object> t = (DataTree<object>) plnB;
    Print(t.TopologyDescription);

    for (int i = 0; i < t.BranchCount; i++)
    {
      GH_Path path = t.Path(i);
      for(int k = 0; k < path.Length; k++)
      {
        Print("[" + i + ";" + k + "] " + t[path, k].ToString());
      }
    }
}

Jachym

Views: 2654

Replies to This Discussion

Hi Jachym
you have to set the var to datatree access when you declare it outside
than you have full datatree access
hope that helps

private void RunScript(DataTree srf, Point3d pt, ref object A)
{
//e.g.
int Bcount;
Bcount=srf.BranchCount();
}
Hi to]

WOW, how did you make it. I set like input for plnB TreeAccess -> Plane but in editor is it still like Plane. How can i change it to DataTree?

Jachym
http://www.grasshopper3d.com/forum/topics/grasshopper-070030-availa...
look@ this post
download the new script component from david
the original one is still broken
Thank you to], i missed this discussion. Now it works fine.

Jachym
Hi Jachym,

have a look in these two examples - they show how to read or make a tree. Like Thomas is saying, you will need the component from here to open the file correctly.

Hope it is useful,

- Giulio
___________________
giulio@mcneel.com
McNeel Europe, Barcelona
Attachments:

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service