algorithmic modeling for Rhino
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:
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;)
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by