Grasshopper

algorithmic modeling for Rhino

Hi Everyone,

I am fairly new to VB and C# so bear with me.  I am trying to set up a script to remove one surface at a time from a list of surfaces until the total area of all of them is smaller than a max area I have set up.  I'm trying to randomize the removal of surfaces so I made a random list of numbers from 0 to the number of total surfaces there are and want the script to pull numbers one at a time that correspond to the surfaces.  Attached are the files that I'm currently working on if this is confusing.  This is the only code I have so far

Dim randomList As New ArrayList
    Dim myFloors As New ArrayList
    Dim sortedAreas As New ArrayList
    Dim tempArea As New Double

    randomList.Add("random_list")
    myFloors.Add("floors")
    sortedAreas.Add("sorted_areas")

    If max_area > current_area Then
      myFloors.RemoveAt(randomList(0))
      tempArea = current_area - sortedAreas(0)
      If max_area > tempArea Then
        myFloors.RemoveAt(randomList(1))
      End If
    Else
      Return
    End If

Hopefully from the files you can see what I'm trying to do, but if not I can clarify as best I can.  Thanks for any help!

Views: 642

Attachments:

Replies to This Discussion

Hi Matthew,

while the 30MB file download runs, here's a non-script way to achieve this.

--
David Rutten
david@mcneel.com
Seattle, WA
Attachments:
And here's a VB script that does the same, except it doesn't wreck the order of the original list of surfaces.

--
David Rutten
david@mcneel.com
Seattle, WA
Attachments:
Thanks so much for your quick reply. Works perfectly! Either one will do what I need, but haven't decided which route to take. Thanks again!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service