Grasshopper

algorithmic modeling for Rhino

I have tried to merge two lists into multiple branches without any luck. Any suggestions? :-)

list1:

{0}[0][1][2]

list2:

{1}[0][1][2]

result should be:

{0}[0][0]*

{1}[1][1]

{2}[2][2]

*[0"list1"][0"list2"] = [0][1] GH

Views: 757

Attachments:

Replies to This Discussion

Attached how I would approach it. Not sure I understand your notation syntax though, this version is just a "flat" tree :)

Attachments:

Thank you for the quick response! :-) :-D :-) :-D :-) 

Hi Again .. I'm a bit confused using "dataTree.AddRange" .. GH Path(i) etc. .. How would you make list merge in python just like the component "entwine" This is not mentioned in any discussion I could find. :-S  (using list access input)

Yes it can be a bit difficult to figure out which methods are available and what they do. Two things help here:

1) Download the Grasshopper SDK Help (under the help dropdown menu in Grasshopper) and look up DataTree .

2) In Python you can always use the help() and dir() methods to inspect an object (like a gh.DataTree for example).

To answer your question. In Python you simple use the addition syntax to merge lists, like so:

a = [1,2,3]
b = [4,5,6]
c = a + b
print c




I'll take a look at the SDK and try to use the help() and dir() functions. 

I don't need to merge list, but I need to put multiple list in branches.

input A: {0}[1,2,3]
input B: {0}[4,5,6]
input C: {0}[7,8,9]

output: {0}[1,2,3] {1}[4,5,6] {2}[7,8,9]

Attachments:

Sry I have been circling around the right solution for some time now and thought i weren't on the right track' :-S 


here's my rough solution:

import clr

clr.AddReference("Grasshopper")

from Grasshopper.Kernel.Data import GH_Path from Grasshopper import DataTree

inputs = [A0,A1,A2]

dataTree = DataTree[object]()

for i in range(len(inputs)):

path = GH_Path(i)

dataTree.AddRange(inputs[i], path)

a = dataTree



...BTW the SDK is awesome! Thanks once again :-D

Hi Thomas,

Check the attached file.

Attachments:

Thanks! I'm gonna use your solution ;-) hehe

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