Grasshopper

algorithmic modeling for Rhino

Dear All,

I'm trying to extract a certain data pattern from 2 lists (of points).
Lets say that I have 2 lists, A and B, and each item in the list as A1, A2, A3...etc and B1, B2, B3...etc. I want to extract A1, A2, B1, B2 as one set, A2, A3, B2, B3 as the second set, A3, A4, B3, B4...etc. as the third set and so on. How can I get about doing this?
Any help would be much appreciated!

Thanks,

Ben

Views: 2559

Replies to This Discussion

I'm not sure if I got you right, but you can use a shift list component to create 4 lists (one starting at A1, another starting at A2, another at B1, and another at B2. Ten graft them and weave it.

I hope it will do the job (maybe its not the cleanest way, but it works for me sometimes. Depending on the ending of the lists you should wrap or not the shift component.

Good luck
Hi Pep,

Thanks for the information. I've created the 4 lists as per your advice but I also flattened them to that each list has the paths 0, 1, 2, 3 and by the graft function it created new branches, but when I run it through the weave command it loses the information? Can you please elaborate on what the graft function does (sorry, I'm not that proficient in data tree management). I attach a screenshot...can you confirm that I'm getting the right results? From there, how can I extract items 4 at a time?
Thanks for your help.

Ben
Attachments:
Hi there, just an update.
I think I managed to get the points I need into branches. How can I then retrieve all of these points within this list structure so that the 4 points in each set can be fed into a srf4Pt component?
Thanks for your help,

Ben

Hi

As you can see, after tha last graft each list has a different index (0,1,2,3). Before weaving, all of them shuold have (I think) the same index (0). If that's not clear attache the file and I'll try to solve it.

Maybe theres somebody around that has a better solution. But for me this ones worked...

Good luck
Hi Pep,

Got it working partially - I had a series of List Item components and had it find the index of 0,1,2,3...but what I didnt expect was that it also extracted each index from each branch....which is where your advice of separating them into branches came in, so it was able to extract the whole list of indexes instead of a single item. Thanks!

The part that doesn't work is an earlier part of the definition to generate the 2 lists in the first place. I'm trying to divide a surface into a specific number of UV points and finding a pattern based on the index of the points so that I can extract the 4 corner points of each subdivided surface. Somehow the logic works with a surface of U,V=20 but when I move the slider for the U or V values the whole list breaks down. I attach the ghx file...am I doing something wrong?


Thanks again!
Ben
Attachments:
I'm not sure if thats what you wanted, but for me it's working just having one slider, that controls the subdivisions. If that's not what you wanted.. then, we will work it out somehow. I attach the definition and u will see a second solution in the same definition attached.

Hope it helps
Attachments:
Hi Pep,

Thanks for your help! Your solution is a lot more streamlined than what I'm trying to do :)
I guess I was making things too complicated by having the extra U (or V) points and generating a lot more points than usual and having to set up extra logic to extract the data. I understand the latter part of the logic of setting up 4 lists with 2 of them having shifted values and getting rid of the odd surface. What I'm curious about is the Cull function at the beginning. Can you tell me a bit more on what it does? It seems that it halved the number of points to work with. How does the True/False come in and what does it evaluate?

Thanks again,
Ben
A good exercise to learn and get practice for working with data trees is to start from scratch, and use the "point list" component (in vector tab) to see how points distribute along a surface. Next step is to understan the logics of what you want to do, in your case, build 4 point surfaces (u also need to know the right direction to build the surfaces). Then you can write an hipotetic list (by hand in a paper) of what you want. In your case the list was (0, 1, 3, 2) (2, 3, 5, 4) (4, 5, 7, 6), etc... if you can imagine building 2 lists, each one with the sequences (0, 2, 4, 6, etcc) and (1, 3, 5, 7, etc..) then you can manage with shift and graft to finally have four lists. A( 0 1 2 3 ...) B (1 3 5 etc..) C(3 5 7 etc..) D (2 4 6 etc..). And to achieve the 2 first lists, you need to get the odd and the pair numbers. The cull pattern does that amazingy well. With a pattern True-False you get de pair numbers, and with the False-True pattern you get de odd numbers.

Hope it was clear enough
Thanks! It was a clear explanation.

Ben

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