Forgot password?

Create an account!


« back

RhinoScript – Bounding box data to text file


Please log in to write a message.

  • 3. muel (Jan 25, 2013 04.41):

    Hi Johannes. I took your advice and had a go at this script and it works in a basic way but only with one part at a time. See my result below. It is a cut and paste of what i could find, and i would really like to loop it, so it could work like "ExportPointsToExcel" with a large list of component dimensions and ideally with part names. Any tips? Anyway thanks for the push in the right direction.

    Option explicit
    Sub BoundingBoxToExcel

    ' Declare local variables
    Dim arrObjects, arrBox, arrDim(2)
    Dim strMin, strMax, strDim, strResults

    ' Pick some objects
    arrObjects = Rhino.GetObject("Select objects for bounding box calculation", 16, True, True)
    If IsNull(arrObjects) Then Exit Sub

    ' Calculate the bounding box
    arrBox = Rhino.BoundingBox(arrObjects)
    If IsNull(arrBox) Then
    Call Rhino.Print("Error calculating bounding box.")
    Exit Sub
    End If

    ' Minimum point is arrBox(0) point
    strMin = "Min = " & Rhino.Pt2Str(arrBox(0))
    ' Maximum point is arrBox(6) point
    strMax = "Max = " & Rhino.Pt2Str(arrBox(6))

    ' Calculate dimensions of bounding box
    arrDim(0) = Rhino.Distance(arrBox(0), arrBox(1))
    arrDim(1) = Rhino.Distance(arrBox(0), arrBox(3))
    arrDim(2) = Rhino.Distance(arrBox(0), arrBox(4))
    strDim = "Dimensions = " & Rhino.Pt2Str(arrDim)

    ' Build big string
    strResults = strMin & VbCrLf & strMax & VbCrLf & strDim

    Dim objXL
    Set objXL = CreateObject("Excel.Application")

    objXL.Visible = True


    objXL.Columns(1).ColumnWidth = 20
    objXL.Columns(2).ColumnWidth = 20
    objXL.Columns(3).ColumnWidth = 20

    objXL.Cells(1, 1).Value = "X"
    objXL.Cells(1, 2).Value = "Y"
    objXL.Cells(1, 3).Value = "Z"

    objXL.Selection.Font.Bold = True
    objXL.Selection.Interior.ColorIndex = 1
    objXL.Selection.Interior.Pattern = 1 'xlSolid
    objXL.Selection.Font.ColorIndex = 2

    objXL.Selection.HorizontalAlignment = &hFFFFEFDD ' xlLeft

    Dim intIndex
    intIndex = 2

    arrDim(0) = Rhino.Distance(arrBox(0), arrBox(1))
    arrDim(1) = Rhino.Distance(arrBox(0), arrBox(3))
    arrDim(2) = Rhino.Distance(arrBox(0), arrBox(4))

    objXL.Cells(intIndex, 1).Value = arrDim(0)
    objXL.Cells(intIndex, 2).Value = arrDim(1)
    objXL.Cells(intIndex, 3).Value = arrDim(2)
    intIndex = intIndex + 1

    objXL.UserControl = True

    End Sub

  • 2. Johannes (Nov 13, 2012 13.44):

    Hi. It is possible and you don't need to be an advanced user...
    There is an Method called Rhino.BoundingBox() to get the edge points. You need to run a loop where you build a boundingbox for each object and a function to exort the point coordinates, dimensions,...

    Here is an example how to export points to excel.

    Take a look to the rhinoscript help file. I think there is an example script for the boundingbox.


  • 1. muel (Nov 07, 2012 12.14):

    Would it be possible to export the x,y,z dimensions given in the bounding box command to a text file or an excel spreadsheet ? Ideally it would possible to select multiple polysurfaces at once to produce a list of part sizes, ie cabinetry cutting list. Is this possible, and if so would you need to be an advanced user to achieve it?


Why are these buttons gray?