algorithmic modeling for Rhino
Hi David, Steve and others!
I am looking the way how can I pass the data from one GHA component (as output) to the other GHA component (as input) using structures.
Example of structure should look like this:
Private Structure MD
'Declare data members
Dim a As Double
Dim b As Double
Dim c As Double
Dim d As string
Dim e As String
End Structure
Registering of the output (in the first component) is done in the following way:
...
pManager.Register_GenericParam("temp", "tempdims","Output")
...
Dim result As New MD
result.a=...
result.b=...
result.c=...
...
DA.SetData(0,result)
Registering of the input (in the second component) is done in the following way:
pManager.AddGenericParameter("temp", "tempdims","Input of dims",GH_ParamAccess.item)
...
Dim MDA As Object=Nothing
If (Not DA.GetData(0, MDA)) Then Return
Dim MDA1 As MD=DirectCast(MDA,MD)
Same structure (MD) is defined in the second component as private type.
While doing the casting with DirectCast I got an error that "Cast method is not valid".
How can I solve the issue?
Should I really define same structure in both components or is there any easier way?
If not, how to perform the right casting?
Thank you in advance!
Kind regards,
Dmitriy
Tags:
All data that is shared between components through wires has to implement the IGH_Goo interface.
What usually happens is that a wrapper class is written for a specific data type (such as System.Int32 or System.String or Rhino.Geometry.Curve) which provides all IGH_Goo required methods and properties for a single instance of that type.
You can use GH_ObjectWrapper to encapsulate your struct, but GH_ObjectWrapper is a last ditch attempt at providing IGH_Goo functionality, it's typically better if you specifically implement IGH_Goo for your type.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David,
Thanks for prompt reply.
As I understood - new class that inherits GH_Goo(of MD) should be used.
Will it be possible to use GH_Goo if I need to include complicated objects like Brep or Surface?
I have looked through the forum and have found few things that can help me to move further to develop my own type, however is it possible to provide a simple example of setting up a custom type in VB?
Appreciate a lot!
Thanks,
Dmitriy
The SDK help files have a topic on deriving from GH_Goo(Of Integer). You can start there.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by