Hey everyone,
this may be a question for absolute beginners, but I can’t seem to figure it out.
Basically I want to build geometries based on some text file contents within Grasshopper and export these geometries into separate files. Here is a MWE for this issue:
There is a csv-like file with 4 columns: index/row, length, width, height. The last three columns are processed with a C#-script and the values are parsed into x,y and z arrays. Based on these arrays I want to build a simple Box (so n boxes for n rows in the file). Every box should then be exported into a separate step-file. Everything works fine and n files are written properly, but they all contain all the n boxes instead of a single box.
Attached is the gh-file and the text file for n=3 boxes. If you wanna use the gh-file please remember to edit the file paths to your needs.
There also may be a lot of other ways to do these things. Any help would be gladly appreciated!
Thanks in advance.
Thanks for your swift reply @Joseph_Oster and your comments on my file.
I read through the script mentioned in the first part of your answer, but it is not exactly what I am trying to achieve. It is used to put all the geometries into a single file. I want to put the geometries into separate files, 1 file for each geometry configuration in the file.
I also ran your edited script. It works, but even though being much cleaner than my script, the issue with the export persists. After adding the export component (from the Pancake plug-in) it also creates three separate files containing all of the boxes at the same time (so file_1.step, file_2.step and file_3.step with 3 breps in each file). Do you have another idea for the file export?
Strictly speaking, I should not have flattened the input to List Length, in case you have multiple geometries in each branch. So I updated my code to use TStat(Tree Statistics) ‘P’ output instead, and added the purple group to generate 10 boxes per branch instead of only one. I also added pcGhFilePath from Kevin’s code so now the parametersToRead.txt file and exported .step files will all be in the same folder as the GH file. That can easily be changed, of course.