View Full Version : Export Rhino Data to Excel...


jamesflett
09-04-2009, 01:26 AM
Hello all, I will cut to the chase.

Is it possible to export surface/solid data from Rhino and link/embed it into MS Excel or vice versa???

Essentially, I would like to be able to export specific dimensions and data such as surface areas and volumes of shapes from Rhino directly into Excel. The reason for this is that I can then run my hydrodynamics program that I have written in Excel without measuring every volume and surface area. Ideally if anyone has ideas on how to run a macro within Rhino to update my Excel inputs OR a macro in Excel to retrieve this data. I assume the latter would be difficult as you would have to make sure that the same component is always selected before and after modification.

Surface areas are for determining my the lift and resistance generated and the volumes for stability/hydrostatics/weight study analysis.

I do have RhinoMarine, however the planing program is very airy fairy with regards to its analysis, and the hydrostatics is not particularly useful past the initial design stage.

I have driven Excel with Solidworks and vice versa back when I was at University so I know it most likely possible.

If anyone has any visual basic knowledge of Rhino in terms of extracting solid and surface data it would much appreciated.

Furthermore, if anyone wants to just drop ANY info on anything related to the above that would also be awesome.

Cheers in advance

Jim

zeroname
09-04-2009, 06:27 AM
i dont know exactly any plugin can do it.. may be experts can tell u.. i only can tell u that both orca3d and rhinomarine can give u the results of calculation and data in MS excel directly.

thanks

SEANT
09-05-2009, 08:08 AM
Here is a very basic Rhinoscript example of that type of Rhino/Excel connection. Run from the Rhinoscript editor

Option Explicit


Sub ExtractProps2XL

' Declare variables
Dim xlApp, xlBook, xlSheet ' Declare variable to hold the reference.
Dim strObject
Dim arrObjects
Dim intCount
Dim arrPoint


'Initialize count
intCount = 0


' Select some objects
arrObjects = Rhino.GetObjects("Pick some (Poly)Surfaces for processing", 24)
If Not IsArray(arrObjects) Then Exit Sub

' Open Excel object
On Error Resume Next
Set xlApp = GetObject(,"excel.application")
If err Then
Rhino.print "Excel not found. Operation aborted!"
Exit Sub
End If
On Error GoTo 0
xlApp.Visible = True

Set xlBook = xlApp.ActiveWorkbook
Set xlSheet = xlBook.ActiveSheet


'Place titles on sheet
xlApp.Cells(1,1).Value = "Mass Properties"
xlApp.Cells(1,2).Value = "Object Identifier"
xlApp.Cells(1,3).Value = "Surface Area"
xlApp.Cells(1,4).Value = "Volume"

'Extract Properties of Surfaces
For Each strObject In arrObjects

If Rhino.IsObjectSolid(strObject) Then
Rhino.ObjectName strObject, "Solid" & intCount
xlApp.Cells(intCount + 2, 2).Value = Rhino.ObjectName(strObject)
xlApp.Cells(intCount + 2, 3).Value = Rhino.SurfaceArea(strobject)(0)
xlApp.Cells(intCount + 2, 4).Value = Rhino.SurfaceVolume(strobject)(0)

End If
intCount = intCount + 1
Next


'xlApp.Quit ' If closing excel is required
Set xlApp = Nothing ' the application, then release the reference.
End Sub

ExtractProps2XL

zeroname
09-05-2009, 04:01 PM
hy seant ,
thanks much.. after i run the script i get one error.
it says. Excel not found. Operation aborted!
though, i have microsoft office 2007 installed.
give a solution.
Thank

SEANT
09-05-2009, 05:52 PM
The script will only attach to an open instance of Excel. Before running the script have Excel open with a blank worksheet active.

Also, the script has only been tested with Rhino 4 and Excel 2003.

zeroname
09-06-2009, 02:18 PM
ok thanks much.. it also works with rhino 4 and excel 2007

View Full Version : Export Rhino Data to Excel...