generative modeling for Rhino
I am looking for a way to use custom Data Type as output from a custom component to another custom component.
but I get an Error: Invalid cast: ObjectWrapper myCustomDataType
I saw a few topics and also the Simple Data Types Help in the SDK..I tried to implement IGH_Goo without any success ..Does someone has some other samples to share ?
I've used the following technique with some success:
For the export of custom data of type CustomDataType:
DA.SetData(0, new GH_ObjectWrapper(CustomDataTypeObject));
and to read it back in, read it in with a generic_param, and
foreach (GH_ObjectWrapper objWrap in Object_WrapperInputList)
CustomDataTypeList.Add(objWrap.Value as CustomDataType);
To be smart about it one should probably define a real custom param type, but this seems to do the trick with a minimum of fuss.
That works great ! Thanks really much Andrew
just go back to the discussion because I have some issues with the GH_ObjectWrapper.
In my custom class I have some list of geometries like Point3d, Line, Curve and Brep. When I try to read it back I can only read Curve and Brep objects type. Point3d and Line are lost..
Does someone already had such issue ? Does some object Type are not working with the GH_ObjectWrapper?
GH_ObjectWrapper is not supposed to work with serialization at all. It's a last ditch effort to allow data of unknown type to participate in a Grasshopper network.
If you want your data to serialize, then you really need to implement IGH_Goo (or derive from GH_Goo<T>). If (de)serialization is not what you meant by "read back in", then you'll need to post some source code so I can have a look at it.
Hi David, ok it's time to try to implement IGH_Goo...thanks.