Paneling Scripts

RhinoCommon Code

Quad Panels

TPG_QuadPanels.jpg
Implemented in a VB.NET scripting component for Grasshopper.
  Private Sub RunScript(ByVal Srf As Surface, ByVal U As Integer, ByVal V As Integer, ByRef Panels As Object) 

    Dim p As New List (Of NurbsSurface)

    Dim ustep As Double = 1 / u
    Dim vstep As Double = 1 / v

    For i As Integer = 0 To u - 1
      For j As Integer = 0 To v - 1
        Dim ptA As Point3d = Srf.PointAt(i * ustep, j * vstep)
        Dim ptB As Point3d = Srf.PointAt((i + 1) * ustep, j * vstep)
        Dim ptC As Point3d = Srf.PointAt((i + 1) * ustep, (j + 1) * vstep)
        Dim ptD As Point3d = Srf.PointAt(i * ustep, (j + 1) * vstep)

        Dim mysurface As NurbsSurface
        mysurface = NurbsSurface.CreateFromCorners(ptA, ptB, ptC, ptD)
        p.Add(mysurface)
      Next
    Next

    Panels = p
  End Sub

Staggered Quad Panels

TPG_QuadStag.jpg
Implemented in a VB.NET scripting component for Grasshopper.
  Private Sub RunScript(ByVal Srf As Surface, ByVal U As Integer, ByVal V As Integer, ByRef Panels As Object) 

    Dim p As New List (Of NurbsSurface)

    Dim ustep As Double = 1 / u
    Dim vstep As Double = 1 / v

    Dim ptA,ptB,ptC,ptD As Point3d

    For i As Integer = 0 To u - 1
      For j As Integer = 0 To v - 1
        If (j Mod 2) = 0 Then
          ptA = Srf.PointAt(i * ustep, j * vstep)
          ptB = Srf.PointAt((i + 1) * ustep, j * vstep)
          ptC = Srf.PointAt((i + 1) * ustep, (j + 1) * vstep)
          ptD = Srf.PointAt(i * ustep, (j + 1) * vstep)

          Dim mysurface As NurbsSurface
          mysurface = NurbsSurface.CreateFromCorners(ptA, ptB, ptC, ptD)
          p.Add(mysurface)
        End If

        If (j Mod 2) = 1 Then
          If (i < u - 1) Then
            ptA = Srf.PointAt((i + .5) * ustep, j * vstep)
            ptB = Srf.PointAt((i + 1.5) * ustep, j * vstep)
            ptC = Srf.PointAt((i + 1.5) * ustep, (j + 1) * vstep)
            ptD = Srf.PointAt((i + .5) * ustep, (j + 1) * vstep)

            Dim mysurface As NurbsSurface
            mysurface = NurbsSurface.CreateFromCorners(ptA, ptB, ptC, ptD)
            p.Add(mysurface)
          End If

          If i = 0 Then
            ptA = Srf.PointAt(i * ustep, j * vstep)
            ptB = Srf.PointAt((i + .5) * ustep, j * vstep)
            ptC = Srf.PointAt((i + .5) * ustep, (j + 1) * vstep)
            ptD = Srf.PointAt(i * ustep, (j + 1) * vstep)

            Dim mysurface As NurbsSurface
            mysurface = NurbsSurface.CreateFromCorners(ptA, ptB, ptC, ptD)
            p.Add(mysurface)
          End If

          If i = u - 1 Then
            ptA = Srf.PointAt((i + .5) * ustep, j * vstep)
            ptB = Srf.PointAt((i + 1) * ustep, j * vstep)
            ptC = Srf.PointAt((i + 1) * ustep, (j + 1) * vstep)
            ptD = Srf.PointAt((i + .5) * ustep, (j + 1) * vstep)

            Dim mysurface As NurbsSurface
            mysurface = NurbsSurface.CreateFromCorners(ptA, ptB, ptC, ptD)
            p.Add(mysurface)

          End If

        End If

      Next
    Next

    Panels = p

  End Sub

Random Quad Panels

TPG_QuadRandom.jpg
Implemented in a VB.NET scripting component for Grasshopper.
Thanks to Saturu Sugihara's piGeon/Processing example for the idea here…
  Private Sub RunScript(ByVal Srf As Surface, ByVal U As Integer, ByVal V As Integer, ByRef Panels As Object) 
    Dim p As New List (Of NurbsSurface)

    Dim ustep As Double = 1 / u
    Dim vstep As Double = 1 / v

    For i As Integer = 0 To u - 1
      Dim j As Integer = 0
      While j <= V - 1

        Dim myRandom As New Random(i + j)
        Dim varlength As Integer = myRandom.Next(1, 10)

        If (j + varlength) > V Then
          varlength = V - j
        End If

        Dim panelpts As New List (Of Point3d)

        For k As Integer = 0 To varlength
          Dim ptA As Point3d = Srf.PointAt(i * ustep, (j + k) * vstep)
          Dim ptB As Point3d = Srf.PointAt((i + 1) * ustep, (j + k) * vstep)

          panelpts.Add(ptA)
          panelpts.Add(ptB)

        Next

        Dim mysurface As NurbsSurface = NurbsSurface.CreateFromPoints(panelpts, varlength + 1, 2, 3, 3)
        p.Add(mysurface)

        j = j + (varlength)

      End While
    Next

    Panels = p
  End Sub

Triangle Panels

TPG_Triangle.jpg
Implemented in a VB.NET scripting component for Grasshopper.
  Private Sub RunScript(ByVal Srf As Surface, ByVal U As Integer, ByVal V As Integer, ByRef Panels As Object) 

    Dim p As New List (Of NurbsSurface)

    Dim ustep As Double = 1 / u
    Dim vstep As Double = 1 / v

    For i As Integer = 0 To u - 1
      For j As Integer = 0 To v - 1
        Dim ptA As Point3d = Srf.PointAt(i * ustep, j * vstep)
        Dim ptB As Point3d = Srf.PointAt((i + 1) * ustep, j * vstep)
        Dim ptC As Point3d = Srf.PointAt((i + 1) * ustep, (j + 1) * vstep)
        Dim ptD As Point3d = Srf.PointAt(i * ustep, (j + 1) * vstep)

        Dim mysurfaceA As NurbsSurface
        mysurfaceA = NurbsSurface.CreateFromCorners(ptA, ptB, ptC)

        Dim mysurfaceB As NurbsSurface
        mysurfaceB = NurbsSurface.CreateFromCorners(ptC, ptD, ptA)

        p.Add(mysurfaceA)
        p.Add(mysurfaceB)
      Next
    Next

    Panels = p

  End Sub

Diamond Panels

TPG_Diamond.jpg
Implemented in a VB.NET scripting component for Grasshopper.
  Private Sub RunScript(ByVal Srf As Surface, ByVal U As Integer, ByVal V As Integer, ByRef Panels As Object) 

    Dim p As New List (Of NurbsSurface)

    Dim ustep As Double = 1 / u
    Dim vstep As Double = 1 / v

    Dim ptA,ptB,ptC,ptD As Point3d

    For i As Integer = 0 To u
      For j As Integer = 0 To v

        If ((i + j) Mod 2) = 0 Then

          If (i > 0) Then
            ptA = srf.PointAt((i - 1) * ustep, j * vstep)
          Else
            ptA = srf.PointAt(i * ustep, j * vstep)
          End If

          If (j > 0) Then
            ptB = srf.PointAt(i * ustep, (j - 1) * vstep)
          Else
            ptB = srf.PointAt(i * ustep, j * vstep)
          End If

          If (i < u) Then
            ptC = srf.PointAt((i + 1) * ustep, j * vstep)
          Else
            ptC = srf.PointAt(i * ustep, j * vstep)
          End If

          If (j <= v - 1) Then
            ptD = srf.PointAt(i * ustep, (j + 1) * vstep)
          Else
            ptD = srf.PointAt(i * ustep, j * vstep)
          End If

          Dim mysurface As NurbsSurface
          mysurface = NurbsSurface.CreateFromCorners(ptA, ptB, ptC, ptD)
          p.Add(mysurface)
        End If

      Next
    Next

    Panels = p

  End Sub

License

The code and components on this page are free software: you can redistribute them and/or modify them under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

http://www.gnu.org/licenses/.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License