Structure Scripts

RhinoCommon Code

Simple Grid

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 Wires As Object) 

    Dim lines As New List (Of Line)

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

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

        Dim ptA As Point3d = srf.PointAt(i * ustep, j * vstep)

        If i < u Then
          Dim ptBu As Point3d = srf.PointAt((i + 1) * ustep, j * vstep)
          Dim myline As Line
          myline = New Line(ptA, ptBu)
          lines.Add(myline)
        End If

        If j < v Then
          Dim ptBv As Point3d = srf.PointAt(i * ustep, (j + 1) * vstep)
          Dim myline As Line
          myline = New Line(ptA, ptBv)
          lines.Add(myline)
        End If

      Next
    Next

    Wires = lines
  End Sub

Grid with Brace

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 Wires As Object) 

    Dim lines As New List (Of Line)

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

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

        Dim ptA As Point3d = srf.PointAt(i * ustep, j * vstep)

        If i < u Then
          Dim ptBu As Point3d = srf.PointAt((i + 1) * ustep, j * vstep)
          Dim myline As Line
          myline = New Line(ptA, ptBu)
          lines.Add(myline)
        End If

        If j < v Then
          Dim ptBv As Point3d = srf.PointAt(i * ustep, (j + 1) * vstep)
          Dim myline As Line
          myline = New Line(ptA, ptBv)
          lines.Add(myline)
        End If

        If i < u And j < v Then
          Dim braceptA As Point3d = srf.PointAt(i * ustep, j * vstep)
          Dim braceptB As Point3d = srf.PointAt((i + 1) * ustep, j * vstep)
          Dim braceptC As Point3d = srf.PointAt((i + 1) * ustep, (j + 1) * vstep)
          Dim braceptD As Point3d = srf.PointAt(i * ustep, (j + 1) * vstep)
          Dim mpt As Point3d = srf.PointAt((i * ustep) + (0.5 * uStep), (j * vstep) + (0.5 * vstep))

          Dim brace1 As Line = New Line(braceptA, mpt)
          Dim brace2 As Line = New Line(braceptB, mpt)
          Dim brace3 As Line = New Line(braceptC, mpt)
          Dim brace4 As Line = New Line(braceptD, mpt)

          lines.Add(brace1)
          lines.Add(brace2)
          lines.Add(brace3)
          lines.Add(brace4)
        End If

      Next
    Next

    Wires = lines
  End Sub

Diagrid

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 Wires As Object) 

    Dim lines As New List (Of Line)

    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 mpt As Point3d = srf.PointAt((i * ustep) + (0.5 * uStep), (j * vstep) + (0.5 * vstep))

        Dim lnA As Line = New Line(ptA, mpt)
        Dim lnB As Line = New Line(ptB, mpt)
        Dim lnC As Line = New Line(ptC, mpt)
        Dim lnD As Line = New Line(ptD, mpt)

        lines.Add(lnA)
        lines.Add(lnB)
        lines.Add(lnC)
        lines.Add(lnD)

      Next
    Next

    Wires = lines
  End Sub

Space Truss

Implemented in a VB.NET scripting component for Grasshopper.

  Private Sub RunScript(ByVal Srf As Surface, ByVal U As Integer, ByVal V As Integer, ByVal Depth As Double, ByRef Wires As Object) 

    Dim lines As New List (Of Line)
    Dim oset As Surface = srf.Offset(Depth, 0.001)

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

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

        Dim ptA As Point3d = srf.PointAt(i * ustep, j * vstep)

        If (i < u) Then
          Dim ptBu As Point3d = srf.PointAt((i + 1) * ustep, j * vstep)
          Dim myline As Line
          myline = New Line(ptA, ptBu)
          lines.Add(myline)
        End If

        If (j < v) Then
          Dim ptBv As Point3d = srf.PointAt(i * ustep, (j + 1) * vstep)
          Dim myline As Line
          myline = New Line(ptA, ptBv)
          lines.Add(myline)
        End If

        If i < u And j < v Then

          Dim lptA As Point3d = oset.PointAt((i * ustep) + (0.5 * ustep), (j * vstep) + (0.5 * vstep))
          If (i < u - 1) Then
            Dim lptBu As Point3d = oset.PointAt(((i + 1) * ustep) + (0.5 * ustep), (j * vstep) + (0.5 * vstep))
            Dim myline As Line
            myline = New Line(lptA, lptBu)
            lines.Add(myline)
          End If

          If (j < v - 1) Then
            Dim lptBv As Point3d = oset.PointAt((i * ustep) + (0.5 * ustep), ((j + 1) * vstep) + (0.5 * vstep))
            Dim myline As Line
            myline = New Line(lptA, lptBv)
            lines.Add(myline)
          End If

          Dim braceptA As Point3d = srf.PointAt(i * ustep, j * vstep)
          Dim braceptB As Point3d = srf.PointAt((i + 1) * ustep, j * vstep)
          Dim braceptC As Point3d = srf.PointAt((i + 1) * ustep, (j + 1) * vstep)
          Dim braceptD As Point3d = srf.PointAt(i * ustep, (j + 1) * vstep)
          Dim mpt As Point3d = oset.PointAt((i * ustep) + (0.5 * uStep), (j * vstep) + (0.5 * vstep))

          Dim brace1 As Line = New Line(braceptA, mpt)
          Dim brace2 As Line = New Line(braceptB, mpt)
          Dim brace3 As Line = New Line(braceptC, mpt)
          Dim brace4 As Line = New Line(braceptD, mpt)

          lines.Add(brace1)
          lines.Add(brace2)
          lines.Add(brace3)
          lines.Add(brace4)

        End If

      Next
    Next

    Wires = lines
  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