Geometry in a custom data type in plugin dissappear when saving

I am creating a plugin where I need to create a custom data type. This custom data type ‘SolutionGoo’ contains multiple data, both numerical and geometrical. SolutionGoo is inheriting from Gh_GeometricGoo and the original data type ‘SOLUTION’
I want to be able to internalize the new data type and save it or transfer it between documents for later use. Although I managed to do that with all the numerical data, only geometrical data get lost after I save the file and reopen it again. If I don’t close the GH file, I can read the geometry just fine. The problem happens only when I save and reopen the file. Thus, I assume the problem is in the Gh_Read method.

I have attached a version of SOLUTION and SolutionGoo classes.

I was following an example by David Rutten, but can’t seem to find it anymore. Will update the post if I find the original example.
It is also the same method to transfer the geometry to byte array as per the example here.

I appreciate any help very very much!

Solution.cs (12.7 KB)

Well … I don’t work with any post R5 build (for the very limited R/GH usage in the practice R5 gen is OK). When storing persistent data into parameter(s) (other than “primitive” types [pts, numbers etc]) … well … that’s a very risky act: in most of cases - when reopening the given GH def - R crashes and the only way to recover/use the definition is to disable the solver and remove the parameter(s). So I never internalize data (better safe than sorry).

Anyway assuming that the next R/GH builds have fixed the above issue … do the following: Store your custom Type List into a parameter, save and reopen the def > If R crashes … well … the issue is still around and you are deep into the rabbit hole.

BTW: Provited that the class declaration is present in both parts ( C#'s or defs) … unboxing a custom Type List from one C# (or from a parameter in a def) to another is done as follows:

Anyway notify if you want an entry level unboxing C# demo:

1 Like

@PeterFotiadis Thank you very much for your thorough answer! I didn’t come across the problem you mentioned as it has been probably fixed as you expected.
In my case, it turned out that by mistake I accidentally deleted a line of code in the param constructor which didn’t allow the geometry to be saved. A very newbie mistake :))