Grasshopper

algorithmic modeling for Rhino

Hi all,

 

I am trying to understand how the datatrees are working in VB. In another post, it is said that GH_Structure has to be called, instead of Grasshopper.DataTree.

My problem is that the casting of GH_Structure elements (i.e. GH_Structure(Of Grasshopper.Kernel.Types.GH_Planes) does not allow me to reuse this geometry as I would like with the rhino.geometry functions.

 

So, is there a way to build a simple datatree of or any geometry, reusable as rhino.geometry stuff?

 

What I try to do is something like this:

With MyCollectionOfPlane as a tree with a simple {A} structure, 1 item by branch.

And with MyCollectionOfPointsForEachPlane as a tree with {A} structure and a list of items by branch.

I wand to have an XY plane on each points of MyCollectionOfPointsForEachPlane, in the good datatree structure.

 

'------------------

Dim MyCollectionOfPlane As New GH_Structure(Of ***planes***)

Dim MyCollectionOfPointsForEachPlane As new GH_Structure(Of ***points***)

Dim MyNewPlanes As new GH_Structure(Of ***planes***)

 

For a as Integer=0 to MyCollectionOfPlanes.Branches.Count -1

For b as Integer=1 to MyCollectionOfPointsForEachPlane(a).Count -1

MyNewPlanes.Add(New Rhino.Geometry.Plane(MyCollectionOfPointsForEachPlane(b), Rhino.Geometry.Vector3d.XAxis, Rhino.Geometry.Vector3d.YAxis)

Next b

Next a

 

DA.SetDataList (0, MyNewPlanes)

'-----------------

 

I'm really stuck on it... I tried to play with .CastTo but had no results... I also tried to wrap geometry with Goo, but I don't understand it very well...

 

Any idea?

Thanks in advance for your help,

TS.

Views: 514

Replies to This Discussion

Hi Thibault,

 

sorry, I don't get it. Are you looking to create a GH_Structure that acts as a single Rhino.Geometry shape? Are you having trouble with the difference between Rhino.Geometry.Plane and GH_Plane?

 

ps. DA.SetDataList(0, MyNewPlanes)  won't work if MyNewPlanes is a GH_Structure. You need to call SetDataTree() instead.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi David, Thank you for your answer.

No I was trying to register a datatree of planes, and use the planes inside like I do when I use lists inputs, my problem is just how can I extract/access to the geometry which comes through my input while keeping the structure of the tree. 

 

If you use GH_Structure as opposed to DataTree then you must use GH_Plane instead of Rhino.Geometry.Plane.

 

GH_Structure(Of T) demands that T implements the IGH_Goo interface. GH_Plane is little more than a wrapper around the RhinoCommon plane though, you can always access the data inside a Grasshopper type via the Value property. So:

 

Dim plane As New GH_Plane(Rhino.Geometry.Plane.WorldXY)

plane.Value = New Rhino.Geometry.Plane(Point3d.Origin, New Vector3d(1,1,1))

 

etc.

 

Typically you do not encounter Grasshopper data types (such as GH_Plane, GH_Curve and so on) unless you want to, but when you work with GH_Structure than you unfortunately don't have a choice.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

 

Ah ok, things get clear!

Thank you for your help!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service