Grasshopper

algorithmic modeling for Rhino

Hi all,

i have a questoin about datatree managemnt in python. I divide 2 curves that are referenced in a curv component and want to make line between them, in gh i would bang the tree and feed the output in the ln component.

How is the procedure in python?

Thanks in advance!

Views: 924

Attachments:

Replies to This Discussion

While it certainly is possible to create and manipulate DataTrees using IronPython, I would really recommend using imperative programming methods/style if you plan to start coding. If you implement the declarative dataflow paradigm of Grasshopper in your Python/C#/VB components you'll probably get into situations where these paradigms start to clash (fitting a square peg into a round hole type scenarios). So, in your example perhaps try to define the implied loop yourself. Here's one example of this:


Hope that helps, even if it is a bit of a mouthful ;)

Edit: Here's a terser version using RhinoScriptSyntax and lumping some calls into the same line:

Attachments:

Hey Anders,

thanks again:) i want to use python also to get rid of the datatrees, just didnt knew how, i thought it would be possible iterating over lists.

Tahnks for the nice example!

regards

Totally agree. I try to write code that knows as little about GH as possible, typically this involves reading input parameter DataTrees (i.e. unpacking them to nested Python lists) and writing them (i.e. wrapping nested Python lists to DataTrees). I rarely write these to more more than one level of nesting and try not to use complex tree paths. If I see that I need to do this, writing objects is almost always a better solution I find (as Tom also points out). That said, Giulio wrote a couple of read/write DataTree functions that do handle arbitrary paths.

hey tom,

nice, like always very helpul explanation and example, thanks a lot for your time!

Will need a while to understand it:)

Feel really stupid for asking,but how did you get the input points structured in 2 branches with 4 items?

regards!

thanks;)

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