Grasshopper

algorithmic modeling for Rhino

Hi Everyone 

As you can see from the picture below I have a lists of lists which I believe in Grasshopper is called a datatree. I am passing this lists of lists into a python component and in that python component I want to be able to access just one list out of these lists of lists.

I am a bit confused about what code I should write in the python component to achieve this can anyone please point me in the right direction? Thankyou!

he right direction?

Views: 1896

Replies to This Discussion

Hi Anton

if you mean that the component should disregard the whole rest of those inputs, then set the desired parameter (right-click) from 'Item Access' to 'Tree Access' and use this code:

a = x.Branch(5) #5 is the index of the branch you want

You can also specify a path, if you know it.

import Grasshopper as GH
a = x.Branch(GH.Kernel.Data.GH_Path(1,2,3))

By the way, panels transform contents to text. Be aware of it if you use those values directly.


If you meant that you needed to access each list, each one singularly, then just use 'List Access'. The component will re-iterate your code the needed amount of times.


You could also inspect in which iteration you are with this code, but I would not suggest it:

iteration = ghenv.DataAccessManager.Iteration

I hope this helps,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Thank you Giulio!

Hi Giulio

I am a bit confused can I asked what is the language of this code? Where can I find more information on how to use this language? For example I would like to create my own component that entwines data.

Thank you!

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service