Grasshopper

algorithmic modeling for Rhino

It's difficult for me to describe the end goal in its actual terms, so I've got a wonky structural explanation here:

I'm feeding in 800 lines of data to a VB script component. Each line contains a z-value to be used for 19 ordered x,y pairs. Every 100 of the 800 lines have the same z-value. My goal is to have a master branch containing branches for each z-value, which contains 100 branches of 19 points (which make use of the z-value).

But I'm stuck at how to output this. I'm reading in the data file line by line, and feeding that into the VB component. My understanding is the script takes each line and executes once, like a for loop. Is there some way that I can have a "global" type of list in the script to contain lists for each z-value? Then I'd simply check what z-value is coming in to determine where to send that data, or something.


I can try clarifying things, as I'm sure I'll need to. ; )

Thanks!

Views: 747

Replies to This Discussion

You can expose existing data structure using the "tree access" option for any input to a vb component...or if you want to create new structure in the component, it also works to input your values as a "list" of data, and then through a series of loops sort and assign them into the data paths you'd like them to be in by declaring a value as a new DataTree.  I'm a bit confused by your explanation as to exactly what you want to achieve...maybe if you post your definition I'd understand better.

That's basically correct. Your input needs to be a list and your output needs to be a tree. It will be very difficult to operate on multiple lists from within a VB/C# component as your output tree needs to be 'grown' in a very specific fashion. However, I can help with this if you need this kind of functionality as well.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

The input is structured like this:

0.2: 0: 1.6,-1.2; 1.1,-0.4; 0.8,-0.1;
0.2: 1: 0.7,-0.0; 0.3,0.2; 1.5,2.1;
0.2: 2: 3.4,1.2; 1.3,-0.1; 2.3,-1.4;
0.35: 0: 2.5,2.3; 1.2,0.2; -2.3,-4.6;
0.35: 1: 4.7,-3.6; 1.5,-3.0; 2.1,-6.7;
0.35: 2: 7.2,-8.1; 6.2,-7.0; 5.7,-2.3;
0.5: 0: 1.5,3.5; 2.3,-0.4; 2.6,-1.2;
0.5: 1: 5.6,-3.1; 5.2,-1.5; 6.3,-6.0;
0.5: 2: -3.4,6.4; -3.0,5.5; -2.9,7.6;

The first number of each line is the z value. Each z value is used multiple times with a list of x,y values. That second number is the index of the list of points for the z value, and the following ordered pairs are the x,y values.


I attached my script, which outputs each line of data as a branch containing the points on that line (paired with the z value at the start of the line). The paths output are {0;0;#} where # ranges from 0 to 799. I'd like to collect all the lines with the same z values into one branch, however, resulting in something like {0;$;#} where $ ranges from 0 to 7 (the number of different z values) and # ranges from 0 to 99 (the number of lists of points associated with each z value), rather than having them all compressed into one list.

I'm reading the input line by line, but if I read it all at once, I could create a loop that examines each line's z value and stores the line into a list specific to that z value, then output all those lists of lists as a list/DataTree? Is that what you are suggesting, David Stasiuk? 

Attachments:

Exactly.  Reference your text as a list instead of a single item.  You're super close...see the attached.

One note...in the logic that I'm using, I'm assuming that a) your text is sorted by z value and b) your desired branches definitely all have different z values. Essentially, I'm increasing a path counter by testing to see if the current z value of the list is different from the previous line of data.  If instead you were doing it by count of line items, you could easily trigger your branch counter that way.

Attachments:

Thank you so much for the help! I've got the data structured as I'd like it. I haven't played around with the results yet, but here's how some curve interpolation looks. I'll be manipulating the different stacks of points/curves based on their height value soon, lofting between them to reveal an evolution in the data. Again, you've been a huge help!

Attachments:

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