Export Rhino Data to Excel...

Discussion in 'Software' started by member 14989, Sep 4, 2009.

  1. member 14989
    Joined: Jun 2006
    Posts: 40
    Likes: 2, Points: 8, Legacy Rep: 32
    Location: NZ

    member 14989 Junior Member

    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
     
  2. zeroname
    Joined: Oct 2008
    Posts: 276
    Likes: 5, Points: 0, Legacy Rep: 90
    Location: Europe

    zeroname Naval Architect

    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
     
  3. SEANT
    Joined: Feb 2004
    Posts: 17
    Likes: 1, Points: 0, Legacy Rep: 34
    Location: Rhode Island

    SEANT Junior Member

    Here is a very basic Rhinoscript example of that type of Rhino/Excel connection. Run from the Rhinoscript editor

    Code:
    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
     
  4. zeroname
    Joined: Oct 2008
    Posts: 276
    Likes: 5, Points: 0, Legacy Rep: 90
    Location: Europe

    zeroname Naval Architect

    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
     
  5. SEANT
    Joined: Feb 2004
    Posts: 17
    Likes: 1, Points: 0, Legacy Rep: 34
    Location: Rhode Island

    SEANT Junior Member

    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.
     
    1 person likes this.

  6. zeroname
    Joined: Oct 2008
    Posts: 276
    Likes: 5, Points: 0, Legacy Rep: 90
    Location: Europe

    zeroname Naval Architect

    ok thanks much.. it also works with rhino 4 and excel 2007
     
Loading...
Forum posts represent the experience, opinion, and view of individual users. Boat Design Net does not necessarily endorse nor share the view of each individual post.
When making potentially dangerous or financial decisions, always employ and consult appropriate professionals. Your circumstances or experience may be different.