Grasshopper

algorithmic modeling for Rhino

Hi guys

I have followed the different threads on writing and reading to/from excel. Does anyone has any luck writing data in specific rows.

I have a surface that is divided into subsurfaces and each one got a value (using a definition to find the location according to the sun) that I would like to represent in excel.

(example of the values from the surface:)

0-4-8
1-5-9
2-6-10
3-7-11

I gives me a list of data: fx: 0-1-2-3-4-5-6-7-8-9-10-11
And would like it to be written in excel:  
Row A: 0-1-2-3 Row B:4-5-6-7 Row C:8-9-10-11 
(so the surface value have the same location in excel as on the surface)

Anyone?

Best
Tore

Views: 733

Replies to This Discussion

Hi Tore
I am assuming that you do it within scripting component. One way to do it is to collect all the values in one list and then wright them into one coma separated string. Just create a loop For i, For j that corresponds to the rows and columns of your subsurface count. And then keep adding characters to the string and in the end of each secondary loop add "carriage return" (it is vbCrLf in VB.NET) character to the string. Then just send this string to the stringPanel and stream content to a .csv file. Then it should give you what you need:

Dim MyVals As New List (Of Double) 'here you collect the actual vals per subSurface

'here do you value collection and store the information in this list
Dim n As integer = -1 'counter

Dim MyStrOut As String 'the string you will output

For i as integer = 0 To RowCount-1
For j as integer = 0 To ColCount -1
n=n+1

StrOut=StrOut & MyVals(n) & ","

Next
StrOut=StrOut & vbCrLf
Next

A=StrOut 'then feed this string to a Panel(String) and Stream content to a myfile.csv

hope it helps
Hi Dima

Thanks alot on that one.. it works perfectly;)
See also the Grasshopper to Excel Exporter from lmnts

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