Visual data - graph

diagram.jpg

Call Main()
Sub Main()
Dim arrPlane
Dim R, ilosc, i, sections, domain, colec, starcurve

Const xlDown = -4121 ‘xlScope
Dim strFileName, dblX, dblY, dblZ
Dim xlApp, xlSheet, nRow, nRowCount
Dim aPoints()
Dim cnt

Dim tekst(), txt
strFileName = Rhino.OpenFileName(”Select File”,”Excel Files (*.xls)|*.xls||”)
If IsNull(strFileName) Then Exit Sub

Set xlApp = CreateObject(”Excel.Application”)
xlApp.Workbooks.Open(strFileName)
Set xlSheet = xlApp.ActiveSheet
nRowCount = xlSheet.Range(”b1″, xlSheet.Range(”b1″).End(xlDown)).Rows.Count

Rhino.Print “Importing data…”

‘Rhino.EnableRedraw(False)

For nRow = 1 To nRowCount

ReDim Preserve tekst(nRow-1)

dblX = xlSheet.Cells(nRow, 2).Value
dblY = xlSheet.Cells(nRow, 3).Value

If IsNull(dblX) Then

xlApp.Quit

Set xlSheet = Nothing

Set xlApp = Nothing

Rhino.Print “Non data found in row ” & CStr(nRow) & “.”

‘ Rhino.EnableRedraw(True)

Exit Sub

Else

rhino.Print dblX
tekst(nrow-1) = array(CStr(dblX),CInt(dblY))

End If

Next

‘Rhino.EnableRedraw(True)

arrPlane = Rhino.WorldXYPlane

strCurve = Rhino.AddCircle (arrPlane, 40)

starting = Rhino.CurveStartPoint (strCurve)

punkty = Rhino.DivideCurve (strCurve, ubound(tekst)+1, True)

For i = 0 To ubound(tekst)

txt = Rhino.AddText (tekst(i)(0), punkty(i), 3)
Rhino.RotateObject txt, punkty(i), 360/ubound(tekst)*i

Next

Call xlIn2(strFileName)

End Sub

Sub xlIn2(strFileName)

‘ Declare variables and constants

Const xlDown = -4121 ‘xlScope
Dim dblX, dblY, dblZ, arr2, point, points
Dim xlApp, xlSheet, nRow, nRowCount
Dim aPoints()
Dim cnt

Dim odl, line, a

a = 41 ‘ number of elements in a column

odl = 35
Set xlApp = CreateObject(”Excel.Application”)
xlApp.Workbooks.Open(strFileName)
Set xlSheet = xlApp.ActiveSheet
nRowCount = xlSheet.Range(”d1″, xlSheet.Range(”d1″).End(xlDown)).Rows.Count

Rhino.Print “Importing data…”
If (nRowCount = 0 ) Then

Rhino.Print “No data range found in file.”

Exit Sub

End If

ReDim aPoints(nRowCount-1)

‘ Rhino.EnableRedraw(False)

For nRow = 1 To a

dblX = xlSheet.Cells(nRow, 2).Value
dblY = xlSheet.Cells(nRow, 3).Value
If IsNumeric(dblY) Then
line = Rhino.Addline (array(0,odl,0),array(0,odl+(-dblY/1000),0))
Rhino.RotateObject line, array(0,0,0), 360/a*(nRow-1)

Else

xlApp.Quit

Set xlSheet = Nothing

Set xlApp = Nothing

Rhino.Print “Non-numeric data found in row ” & CStr(nRow) & “.”

Rhino.EnableRedraw(True)

Exit Sub

End If

Next

End Sub


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply