Grasshopper

algorithmic modeling for Rhino

Greetings,

 

I'm trying to add data to an empty data tree (in a custom VB.net component) and I'm getting an index error when I try to access it. I presume this is happening because it's empty an uninitialized. I also assume that an efficient way of doing this to use the GH_structure class. Particularly because I want the structure to match one of my input datatrees. The problem is I don't understand how to use the GH_structure class... of primary importance the copy structure constructor. I'm stuck at the very outset, I can't even declare a variable:

 

Dim struct As New GH_structure < Ofcurve>

 

I'm getting an expected end of statement error and I can't really understand the SDK. Can someone post a simple example of how to take an existing DataTree's structure and copy to an new empty datatree?

 

Thanks!

Views: 919

Replies to This Discussion

There's a ClearData() member on DataTree. This will remove all items but it will maintain all branches.

 

GH_Structure(Of T) requires that T be of type IGH_Goo, so you cannot make a GH_Structure of a Curve. While inside a script component, it's best to stick to the DataTree type.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi guys!

i'm having a problem with custom components and data trees, so maybe this is the thread to be:

 

I'm developing a class in VS2010, to be used with VB.net components

In a nutshell, the class represents parametric solids resulting from an extrusion along path

a particular method subdivides a class instance in, let's call it, VW sub-solids (as opposed to UV), and in the end I want the sub-instances to be accessible by their array indexes, but I guess in GH the only way to do it is through datatree

 

I found the code to create datatrees, but the thing is that since I'm compiling the code in VS2010, I'm guessing it doesn't find the namespace for the datatree.

If this is the problem, which dll/assemblies do I have to reference/import?

If not, what could it be?

 

If you find it convenient, I'll upload the GH file as well as vb.net code.

 

Thanks in advance,

Eduardo

 

DataTree is declared inside the Grasshopper.dll file. You'll need to reference this dll if you want to use DataTree. You may also need to reference GH_IO.dll as a lot of Grasshopper.dll depends on GH_IO.dll.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thank you David!

Best Eduardo

Thanks David!

That really did the trick. (also it helps to use paths when you are adding to a DataTree...) oops. It seems coding is not like riding a bike.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service