Grasshopper

algorithmic modeling for Rhino

hi everyone,

I´m trying to script a tree with branches and subbranches. does anyone know how to do it?

I was thinking about making a list of trees and then the branches, but then I bumped into the treebuilder class. is it the solution to this problem and what are the constructors and members?

cheers

Views: 371

Replies to This Discussion

Gh data tree is what you are looking for... There are examples posted here, google them (sorry I don't have the link handy from iPod).
This came up a few weeks ago over on the scripting discussion board... http://www.grasshopper3d.com/forum/topics/using-the-grasshopper-tree
Luis and Damien,

thanks for your answers. I read the threads you comment but I think I didn´t get an answer or at least I didn´t understand.

With the DataTree class I have gotten to make a simple tree structure like this:

DataTree Tree = new DataTree();

for (int i = 0; i < nums.Length;i++)
{
GH_Path Path = new GH_Path(i);
Tree.Add(nums[i], Path);
}

A = Tree;


And I get the tree of the image below.

But my question is wether it is possible to write data, not only into paths, but also into subpaths in the very same tree and to have in the end a structure with:

{0;0}
{0;1}
{0;2}
{0;3}

{1;0}
...

and so on

I couldn´t make it work or don´t know if I missed something.

Thanx
Attachments:
You can add subpaths in the GH_Path constructor. Merely add more than one number:

new GH_Path(i, j)

and you get nested branches.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
great! that´s exactly what I needed.

thanx, david.

by the way, I´d like to ask you what a GH_Structure is. I stumbled upon it while I was looking for branches. does it has anything to do with a tree structure?
GH_Structure is the class I use internally to represent Trees. DataTree is the "kiddie" flavour of GH_Structure. It's very easy to shoot yourself in the foot with GH_Structure btw. and I'm not sure if the Script components can actually detect it at this stage.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
ok, then I won´t play with GH_Structure for the moment!

anyway, I think it would be useful to be able to define the input parameters in the script components as a DataTree.

I don´t know anyway to acces the branches of an inherited structure in the variables, like: x.Branch(i) or whatever.

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