Grasshopper

algorithmic modeling for Rhino

simple question, what's the syntax for reading from a data tree?

normally I would use an integer of each item in a list in brackets as in list(i)

when i have a tree where each branch has two forks...as in:
[0:0][0:1][0:2], [1:0][1:1][1:2], [2:0][2:1][2:2]...and so on

how do I read each branch? I am kind of lost here...the first two branches will only have one item while the third will have a few. If anyone can point in the direction of some documentation or tutorial I would really appreciate it...

thanks!

Views: 3624

Replies to This Discussion

by a long trial and error search i figured out a bit...but if anyone could point me to more elaborate instructions i would be extremely grateful...

what i figured out...for anyone else looking...
Tree.Branch(0).Item(0)

where tree is the datatree, branch refers to the index of the branch off the main index, and item refers to the index number of the item within that list
hi gabriel
currently it is not possible to read data trees direct into vb.net components
you have to reconstruct them insider your script with lists which describe your tree structure and their corresponding values
-to]
Thanks. I may be overlooking something, but I should clarify that I constructed this datatree inside my vb...it is built, I am just having trouble figuring out how to access its 'leaves'...
YEAH so while i can access all the branches in the aforementioned example, i am not sure how to get one exact path...Branch(0) will access all branches that begin with 0...any ideas?
update: if you construct a new path with the target path routing and then feed this variable into the branch argument, you have access to that unique branch....so i have it sorted out in the end. strange that there's no place for answers...
Would you consider uploading your definition for reference...?
I have been on the lookout for these sort of things as well, but without much luck yet....
hey,

i think i may have made a simple but large mistake - i don't think i even need the eh_path for a data array in vb...i think i can make it like you would normally make an array. I guess i got confused with those vb scripts that need their trees visible outside the component - mine is only on the interior.

I could post the code but I'm not sure how useful it would be to you - it's very specialized to a particular use,..

so back to normal arrays - anyone care to help refresh mymemory how you would make an array where each row has three columns, but the third has a list within it? would that make it a 3d array? basically a structure where each 'entry' has (0,0) and (0,1) of single integers but (0,2) is a list of integers?
--0 1 2
0 5 0 1,5,4,3
1 6 0 4,7,3,6
2 2 1 5,9,3,2
3 1 0 4,6,5,7
4...
Attached is one way to extract branches using GH components.
i hope this is helpful.
Attachments:
This is really useful to know, but I still don't understand why it works?
THIS IS INCREDIBLY HELPFUL. Who'd have thought? A list of path names is exactly what I needed.
thanks rajaa

i am pretty familiar with that sort of component use. what i've been having trouble is playing with the data in a vb script component. the algorithm is recursive and I don't think i would be able to do it with components. how might you construct a vb array like the one i need, where one column or entry might be a single integer while another will be filled with several integers -


one column or entry would be a single integer, like 0, 1, 2, 3, 4... - i need this as an index of each one's position in the list

the second would be 0 or 1, or true or false

the third would itself be a list of integers 0,4,5,2,7,2,5,2...

so all together one entry would be {0; 0; 0,4,5,2,7,2,5,2}
while the next might be {1; 0; 6,8,2,5,2,3}

I've figured out how to write and output a datatree internally within vb that subscribes to exactly this structure but I find navigating it kind of confusing - i wonder if i should be using plain old vanilla vb arraylists? at one point in my algorithm i need to change the value of a leaf on the tree and I found that when I did this - datatree.branch(path).item(integer) = 1 - my tree went funny...it didn't behave as I was expecting...

any advice?
Hi,
When constructing the tree, you probably should end up with something like:

(0; 0){1,4,5,2,7,2,5,2}
(0; 1){6,8,2,5,2,3}
(0; 2){0,4,5,2,7,2,5,2}
(0; 3){4,88}
(0; 4){0,7,2,5,2}
(0; 5){6,5,8,2,5,2,3}

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