Grasshopper

algorithmic modeling for Rhino

Hi Everyone !

I have a simple question which gives me sleepless nights. I want to add lists of data from plenty of independent trees.

example:

[[0,1,0],[0,1,0],[0,1,0]] + [[2,3],[2,3]] = [[0,1,0],[0,1,0],[0,1,0],[2,3],[2,3]]

How to script it in python?

If I break down trees and then independetly add lists, it works somehow like entwine in grasshopper, but lists are dynamic and the number of them in the tree as well, additionally number of trees might grow.

Please look at the attachment.

p.s. I think I have read all topics on that issue but I could not find satisfactory answer.

Views: 1805

Attachments:

Replies to This Discussion

HI Radoslaw

Check the attached files


Attachments:

Well, there is still a small issue as the script works only if trees have different structures. If you simplify them the script adds lists inside branches with the same index. Attached image represents this behaviour.

Additionally, you forgot to create empty list of b in the given script in the file. I added b=[] before the i for loop and it certainly works in the situation you provided. As I said it doesn't if trees are of the same structure. i.e {0}, {0} or {0;0} {0;0}

Thank you for your engagement

Attachments:

HI Radoslaw

  I am very sorry,Made two small mistakes,I rewrote the code.Check the attached files

Attachments:

Thank you NARUTO, it works perfectly.

Just for my understanding and for others:

The script counts branches in the first list and add to the path list, then for each path adds the list of the Grasshopper path and then do the entire calculation for the big for loop by adding the next tree. In other words it dismantles each tree independently and put them together into one.

The last part of the script is just translation of the tree to Grasshopper.

How did you learn How did you learn Trees in Python? There is not much documentation in the internet. I found only help of Grasshopper SDK

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