Grasshopper

algorithmic modeling for Rhino

Injecting one data stream to another (combine values)

I have feeling that this might be a really easy question for some people, but I couldn't figure out. X(

stream 1
(a1, b1, c1)
(a2, b2, c2)
(a3, b3, c3)
....

stream 2
(d1)
(d2)
(d3)
...

I want to get this target list:
(a1, b1, c1, d1)
(a2, b2, c2, d2)
(a3, b3, c3, d3)
....


What I want to do is injecting one more value (arbitrary angle in my case) to each point before I cull many of them - so that each point brings its angle data along. 

Any hep would be greatly appreciated. TIA


Views: 1244

Replies to This Discussion

If the tree layout of the ABC and the D data is identical, then just merging the two streams (in the correct order) will append all items in D to the end of all lists in ABC.

But you will need to make sure that the paths for {a1, b1, c1} and {d1} are identical.

You can use a ParamViewer to see these paths, and use a Path Mapper to adjust them.

--
David Rutten
david@mcneel.com
London, UK
David,

Thanks for the input. I think I wasn't clear enough though.

Let's say I have a flattened list of 5 points
1, 1, 1 ... 5, 5, 5 {0} (N=5) as appeared in the param viewer

and I have another flattened list of numbers
100, 200, 300, 400, 500 {0} (N=5)

'Merge' would give me:
1,1,1
2,2,2
3,3,3
4,4,4
5,5,5
100
200
300
400
500

A target list I want is:
1,1,1,100
2,2,2,200
3,3,3,300
4,4,4,400
5,5,5,500

I hope this is more clear.
"a flattened list of 5 points" or 15 points?

I'm confused.

--
David Rutten
david@mcneel.com
London, UK
In GH (and .NET) points are not simply an array of 3 numbers like in Rhinoscript, so you can't just add a 4th value in there.
Do something like this: Connect a graft component after the point output, connect a graft component after second flattened list, decompose the points in XYZ, connect these 3 outputs + the grafted second list to a merge component with 4 inputs. You should end up with 5 branches of 4 elements each.
I see where you got confused/I made you confused.

the first list is (for example) x,y,z coordinates of 5 points.
You could use an expression with String formatting functions to create "1,1,1,100" (you'll need two expression inputs, a point and a number, let's call them P and N). The formatting string is:

Format("{0},{1},{2},{3}", P.x, P.y, P.z, N)

Then you can use the new StringSplit component in 0.7 to break the string apart at the commas...

But I prefer Vicente's solution, it's cleaner.

--
David Rutten
david@mcneel.com
London, UK
Thanks a lot for the answers guys.

Thanks for the answers and thanks for asking the question.
I was just facing the same problem.
This forum is very helpful.
 

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service