McNeel Wiki
Arraying Points on a Surface
edit · print · help · all topics
Main Pages

AccuRender

Bongo

Brazil r/s

Developer

Flamingo

Penguin

Rhino Blogs

Rhino

Rhino Labs

Search

Languages

Česky

Deutsch

English

Español

Français

Italiano

Polish

日本語

한국어

中文(繁體)

中文(简体)

 
.
DeveloperRhinoScript
SummaryDemonstrates how to array points on a surface using RhinoScript.

Question

I was wondering if there is a way to extract uv surface coordinates in Rhino. Specifically I'm trying to extract UV's of points on a surface and export it to a text file.

Answer

Yes. The following script will array points on a surface. When finished, simply export the selected points to a Points File (.txt).

  Option Explicit


  Sub ArrayPointsOnSurface()


    ' Get the surface object
    Dim srf : srf = Rhino.GetObject("Select surface", 8, vbTrue)
    If IsNull(srf) Then Exit Sub


    ' Get the number of rows
    Dim rows : rows = Rhino.GetInteger("Number of rows", 2, 2)
    If IsNull(rows) Then Exit Sub
    rows = rows - 1


    ' Get the number of columns
    Dim cols : cols = Rhino.GetInteger("Number of columns", 2, 2)
    If IsNull(cols) Then Exit Sub
    cols = cols - 1


    ' Get the domain of the surface
    Dim U : U = Rhino.SurfaceDomain(srf, 0)
    Dim V : V = Rhino.SurfaceDomain(srf, 1)
    If Not IsArray(U) Or Not IsArray(V) Then Exit Sub


    ' Turn off redrawing (faster)
    Rhino.EnableRedraw vbFalse


    ' Add the points
    Dim i, j, t(1), pt, obj
    For i = 0 To rows
      t(0) = U(0) + (((U(1) - U(0)) / rows) * i)
      For j = 0 To cols
        t(1) = V(0) + (((V(1) - V(0)) / cols) * j)
        pt = Rhino.EvaluateSurface(srf, t)
        If IsArray(pt) Then 
          obj = Rhino.AddPoint(pt) ' add the point
          Rhino.SelectObject obj   ' select the point
        End If
      Next
    Next


    ' Turn on redrawing
    Rhino.EnableRedraw vbTrue


  End Sub
rename · changes · history · subscriptions · lost and found · references · file upload