Flatten a tree



Hi all,
i tried to flatten a tree but i donts know how to tell the path…i thought {0}
but that seems wrong

import Grasshopper as Gr
print R


Help is welcome

(Lando Schumpich) #2

Well it’s all in the error message:
You have to construct a Gh_path and pass that to flatten, not just an int that looks like a path

(jesterKing) #3

The { 0 } is a set


Yea i know because the error information tell me this …but i dont know what this hint mean…i am just a python noob and if i see set its for me like this.
set() …i guess you guys are far more experienced than me.
but thanks for your information

(Lando Schumpich) #5

hey @flokart i think i could have worded that better, I’m sorry.

The error message means that the flatten function( or method) expects a very specific type of object, a GH_Path. The link i provided you explains what a GH_Path is, how it can be constructed, and additional info about its methods and properties. I fully understand that the documentation will be very hard to read if someone is starting out with programming, for me it helped a lot to learn about object oriented programming (OOP) to better understand why and how all this different objects in rhino work.

Here is a working code sample:

If you have more questions or problems feel free to ask


Thanks a lot lando