Forgot password?

Create an account!


« back

RhinoScript – Export point data with connectivity


Please log in to write a message.

  • 6. Sherizadeh (Feb 16, 2013 12.21):

    Dear John,

    It looks that I am looking for the exact thing you were looking for. I am trying to export these points to a Numerical software (3DEC). That would be great if you let me know about any success for writing this script.

    Thank you.

  • 5. jmc (Mar 13, 2012 11.26):

    Thanks Johannes, I am trying to redraw the lines in a numerical software package thats a bit Neanderthal in terms of inputing geometry (hence the simple crack x,y syntax). I will take some time but hopefully I can change the script enough to suit my needs. Sometimes I may have as many as 2000 lines of text (many polylines and points!) so I may try to figure out how to export it straight to a text file. I'm sure there will be a command somewhere that will do this.

    Thank you again and I will let you know if I manage to get it fully working for my needs. I just need to figure out how to only have 2 sets of points in one line (this might be the Dimension of the array? 2 instead of 4? and to change it to 2D xy coordinates I may need to lose an array point (arrPO(ii)(2)? this is my guess and I will see if it works. keep your fingers crossed.

    Many thanks, John

  • 4. Johannes (Mar 12, 2012 21.18):

    hey john, where do you want to redraw polylines done in rhino? You need to loop through your polylines to export/group/print the points. Then you know the correct order. Here a short similar script...

            Dim arrPL       : arrPL = Rhino.GetObjects("Pick polylines", 4)
            Dim i, ii
            Dim arrPO, strTX
            For i = 0 To Ubound(arrPL)
                    arrPO   = Rhino.CurvePoints(arrPL(i))
                    strTX   = "crack "
                    For ii = 0 To Ubound(arrPO)
                            strTX = strTX & " " & _
                                    arrPO(ii)(0) & "," & _
                                    arrPO(ii)(1) & "," & _
                    Call Rhino.PrintEx(strTX)

    have fun!

  • 3. jmc (Mar 12, 2012 20.34):

    Hi Johannes, what I need is the coordinates to be output in an order that would draw exactly what is done in Rhino. If I use the script below I just get a semi random output of coordinates with no indication of what ones were originally connected by polylines in the rhino file.

    To explain properly below are the stages and aims of my problem:
    1. I draw a number of polylines in a rhino file
    2. I extract points
    3. select points to be exported by a blanket select over the whole drawing/model
    4. Load the script below to export all these point coordinates to excel
    5. I then need to reconstruct the coordinates into an ASCII file for another program so it can draw exactly what was done in Rhino. This is in the format of;
    crack x1,y1 x2,y2
    crack x2,y2 x3,y3 etc..

    so for coordinates of 3 polylines of
    0,0 to 2,2
    2,2 to 4,4
    4,4 to 6,8
    6,8 to 8,10

    and also a line that join points 2,2 to 2,8 then 2,8 to 2,10
    and another that joins points 2,2 to 1,10

    The resulting ASCII file needs to look like this:

    crack 0,0 2,2
    crack 2,2 4,4
    crack 4,4 6,8
    crack 6,8 8,10
    crack 2,2 2,8
    crack 2,8 2,10
    crack 2,2 1,10

    This makes sure that all points are joined to the specs of the original drawing hence the topology is maintained. Otherwise just exporting a bunch of coordinates to a spreadsheet doesn't let me keep the coonectivity relationship between points so the shape can be re-drawn exactly in the new crack x1,y1 format.

    I hope this makes some sense :)
    Any help greatly appreciated


  • 2. Johannes (Mar 10, 2012 21.27):

    Hi, what excactly do you want to do? Actually you select points to export the x,y,z coordinates into an excel sheet. What about the connectivity? How is that defined?

    here is your script with a description:

    Sub ExportPointsToExcel()
            ' pick some points in rhino
            Dim arrPoints   : arrPoints = Rhino.GetObjects("Select points to export", 1, True, True)
            If Not IsArray(arrPoints) Then Exit Sub
            ' open excel
            Dim objXL
            Set objXL = CreateObject("Excel.Application")
            objXL.Visible = True
            ' new workbook in excel
            ' pastze some strings into specified cells
            objXL.Cells(1, 1).Value = "X"
            objXL.Cells(1, 2).Value = "Y"
            objXL.Cells(1, 3).Value = "Z"
            ' export the point coordinates into excel
            Dim strPoint, arrPt
            ' loop to run trough each selected point
            For i = 0 To Ubound(arrPoints)
                    arrPt = Rhino.PointCoordinates(strPoint)
                    objXL.Cells(i+2, 1).Value = arrPt(0)
                    objXL.Cells(i+2, 2).Value = arrPt(1)
                    objXL.Cells(i+2, 3).Value = arrPt(2)
            objXL.UserControl = True
    End Sub


  • 1. jmc (Mar 09, 2012 21.43):

    Hi, I am really new to both Rhino and programming (still a real beginner) and I would like advice/help on trying to write a script that exports not only the points from a rhino model but deals with the connectivity or topology as well. So points connected by polylines are exported into an excel sheet.

    Say polylines are drawn that connect the following x y coordinates (lets keep it simple in 2D within a 10 by 10 square)

    0,0 to 2,2
    2,2 to 4,4
    4,4 to 6,8
    6,8 to 8,10

    and points 2,2 are also connected to 2,8
    and points 2,2 are also connected to 3,10

    If I simply export the points without understanding how they are connected it can cause problems in a more complicated model. I have tried the excel output script below but it doesn't deal with topology.

    Any help appreciated

    Sub ExportPointsToExcel()
       Const rhPoint = 1
       Dim arrPoints
       arrPoints = Rhino.GetObjects("Select points to export", rhPoint, True, True)
       If Not IsArray(arrPoints) Then Exit Sub
       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
       Dim strPoint, arrPt
       For Each strPoint In arrPoints
         arrPt = Rhino.PointCoordinates(strPoint)
         objXL.Cells(intIndex, 1).Value = arrPt(0)
         objXL.Cells(intIndex, 2).Value = arrPt(1)
         objXL.Cells(intIndex, 3).Value = arrPt(2)
         intIndex = intIndex + 1
       objXL.UserControl = True
      End Sub


Why are these buttons gray?