Grasshopper

algorithmic modeling for Rhino

Hi,

I'm trying to realize a Component with VB. I'm already have done it with Clusters, but now I want to program it in VB.

The Component should output the following panel:

So it should be a Datatree where in the first list {0} is/are Breps, in the second {1} Lines and in the last {2} Numbers.

In the Cluster it is done by the Merge Component. My Question is: Is it possible to do this in VB?

In the Sub RegisterOutputParams I'm using the pManager.AddGenericParameter , is this the right one for this problem ??

And then how can I create this datatree (I think it's not Dim ... as List(of ...), or is it??

Thanks for all your help.

Nice greets

Alex

Views: 1364

Replies to This Discussion

Hi,

if you are using VS , then you should use the class and methods of GH_Structure(of T). It's different than the VB scripted components.

M.

Hi Marios,

thanks for your fast reply. I don't have GH_Structure(of T). What do I have to implement?

And what kind of "T" do I have to use ?

Thanks.

Alex

If you are scripting inside GH then Florian has already given you the answer in C#, on the other hand if you work on Visual Studio you should import Grasshopper.Kernel.Data and then you can access the GH_Structure(of T) Constructor. T should be of type IGH_goo

Best,

M.

Thanks Marios,

this helps a lot. I'm doing this in VS and so this is the thing I was searching for. Another last question to this topic:

I'm now using....

Dim data As GH_Structure(Of IGH_Goo)
data.Append(surf2, New GH_Path(0))

data.Append(line, New GH_Path(1))

data.Append(number, New GH_Path(2))

to append data to the the GH_Structure. But then there comes the error, that Double can't be converted in IGH_Goo. How can I solve this?

Nice Greets

Alex

Thanks for all your help.

Alex

You need to change you variables to type of igh_goo. Ie double should be gh_number.

Is there a possibility to cast GH_Number from Double? Or how should I convert them ?

What do I make wrong??

Dim line As Line
line.From = point1
line.To = point2

Dim line_gh As GH_Line
line_gh.Value.From = point1
line_gh.Value.To = point2

The first sector works. But when I do the same thing with GH_Line then it doesn't work ??

Sorry, I am on route!! You could use gh_convertTo or declare them as gh_number from the beggining!!

is this what you want to do?

Attachments:

Thanks for the code, this is a part of what I was searching for. But I'm coding in Visual Studio and not inside GH. But thanks for your help.

Alex

Dim breps As New List(Of Object)()
Dim lines As New List(Of Object)()
Dim numbers As New List(Of Object)()
For i As Integer = 0 To 9
lines.Add(New Line(i + 1, i + 1, i + 1, i + 4, i + 4, i + 4))
breps.Add(Brep.CreateFromBox(New BoundingBox(i + 1, i + 1, i + 1, i + 4, i + 4, i + 4)))
numbers.Add(i / 1.1)
Next
'''//////////////////////////////////////////
' NOW IT BEGINS //
Dim yourData As New DataTree(Of Object)()
yourData.AddRange(breps, New GH_Path(0))
yourData.AddRange(lines, New GH_Path(1))
yourData.AddRange(numbers, New GH_Path(2))
A = yourData

 

this is the vb code...sorry i just realized you're writing in vb ... i don't know if you know http://converter.telerik.com/ its a really nice and reliable online code converter i use it all the time.

 

This code works in VisualStudio too. You just have to get sure about these using directives (but they sould already be there when you used the VS wizard):

using Grasshopper; //for DataTree<>

using Grasshopper.Kernel.Data; //for GH_Path

Then you can do: DA.SetDataTree( int paramIndex, IGH_DataTree tree )

very simple isn't it ;-)

Hi Florian,

Tanks for all of your tips and for the massive help !!!

Somehow now I've got it running ... Now is time for playing around with it ..

Nice greets

Alex

Hi,Florian

Where I can find references about DataTree class in rhinocommon SDK?

Thanks

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