Grasshopper

algorithmic modeling for Rhino

I was wondering if anyone had information on using Grasshopper's tree class. There doesn't seem to any documentation, but maybe I don't know where to look.  I need to be able to do something similar to the code below, but instead of with a System.Collections.Generic.list with the grasshopper trees list type. If Grashopper's tree class doesn't have an insert, remove or some sort of replace function, can I convert the tree class into an Arraylist?
     
   Just a thought, but don't mistake me throwing out these techy terms as any real knowledge. . . . A week ago I had no idea what a class or method was!

   Basically I need to be able to replace one point on a list, within a specific branch with the corresponding point (which has been projected) from another list.I can not, for various reason  dynamically re-map this list into branches which I know how to do. I need to retain the branch structure going in.

  Private Sub RunScript(ByVal in_pntList1 As List(Of On3dPoint), ByVal in_pntList2 As List(Of On3dPoint), ByRef out_pntList As Object)
    'delcare variables
    Dim i As Int32
    For  i = 0 To in_pntlist1.Count - 1
      If in_pntlist1(i).x < in_pntlist2(i).x Then
        in_pntlist1.insert(i, in_pntlist2(i))
        in_pntlist1.removeat(i + 1)
      End If
    Next

    out_pntlist = in_pntlist1

FYI The ultimate goal is to partially project a helical curve onto a surface based on wether it is "inside" or "outside" of that surface. Luckily the surface is aligned to the orthagonaly to the y axis so i can get away with comparing x co-ordinates. The BRep inclusion component seemed a bit feisty.

Best,

Ben

Views: 2545

Replies to This Discussion

David distributed a small example when he added data trees. I think this one is it... both VB and C#
Attachments:
A heads up to anyone lookig at this script the type 'EH_Path' is deprecated and needs to be replaced with 'GH_Path'
Damien,

I took a look at the vbscript you enclosed and created an instantiation of the Datatree class so I could have access to the "hints" that pop up in the script editor. I don't see any method that would allow my to insert or remove any items within the data tree. (see below if Jpg uploaded) ]
Is their a work around for this? I guess I would have to move the data from each branch into a separate list, then replace the points using the insert and remove routine above of the System.generic list class, and then place these lists back into the tree. Since their are no methods in the Grasshopper.datatree class for doing this the only way I can see is by using a series of loops and calling each item of each branch separately. . . Is this correct or is their a better way?

PS Is their a place for me to download the Grasshopper SDK?

Best,

ben


Hi Benjamin
First of all: Basicaly the Tree Class is able to do everything is possible inside Grasshoppers graphical interface (nothing more).
You can Add, Remove, Flatten, create Paths and so on.
I did some things with the tree class in vb to make custom tree structure.

I sometimes use flatten lists + branch information lists to make custom trees. So later i can use the same branch information list to do same trees with other information. In this way i'm able to keep all things synchronized. In your case its a bit different, but anyway i think you can use the example and try to do your own algorithm. Hope this helps you in some way.

Good luck and greets Florian Frank

tree_class_example.ghx
Thanks Florian for your reply It looks like this script might come in handy in the future. . . . Funny thing is somehow my script worked just as is. I think perhaps Vbscript automatically typecasts the trees as a list of lists and then grasshopper typecasts this back into data trees?

Given my dificulty with classes, ie Oncurves Nurbescurves, etc I assumed that it wouldn't work.

When I finally finish this definition I will post it up. I think its an interesting problem, a spiral stair deformed by a surfaces, and I now have attacked the problem from a variety of methods.

Best,

Ben
Yes somehow it's like you said a list of a list...if you don't know how to use the classes look at the rhino .net sdk...there are listed all the classes and consequently all the members of those... for vb and csharp...just download it at the mcneel site if u don't have it already ;-)
Wish you good work and keep on, want to see results :-)
greets Florian Frank

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service