Grasshopper

algorithmic modeling for Rhino

i finally solved all my problems. the code runs perfect. sorts the cellular automata points. as input you need a list of 3d CA grid-points. the code looks for all points with a neighbor directly in front. outputs 2 lists. a with neighbors in front and b without.

i have attached a final screenshot, a rhino testfile with ca points and the final definition.

this is the code:


    'Declare and Initialize data

    Dim i As Integer = 0
    Dim j As Integer = 0

    Dim pts_count As Integer = pts.Count() - 1

    Dim new_ptsA As New List(Of On3dPoint)
    Dim new_ptsB As New List(Of On3dPoint)

    Dim temp_pt1 As On3dPoint
    Dim c As Integer = 0

    'Loop through base points

    For i = 0 To pts_count
      c = 0
      For j = 0 To pts_count
        If pts(j).x = pts(i).x And pts(j).z = pts(i).z And pts(j).y = pts(i).y - 10 Then
          Print("neighbor in front")
          temp_pt1 = pts(i)
          new_ptsA.Add(temp_pt1)
          c = 1
        End If
      Next
      If c = 0 Then
        Print("NO neighbor in front")
        temp_pt1 = pts(i)
        new_ptsB.Add(temp_pt1)
      End If
    Next

    'Assign new points

    A = new_ptsA
    B = new_ptsB


be aware that the code assumes a grid width and depth of 10x10.

volker.

Views: 639

Replies to This Discussion

here are the files:
Attachments:
my last screenshot for tonight. i finally got all constellations working. the code is quite long now, but i will ask tomorrow how to optimize it.
Attachments:

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service