Custom Type can it be done from GH_Python?

I can’t answer to python, but for C# only part of this is possible.

You can create a new type inside a script component which implements IGH_Goo or one of its derived types/interfaces. This type will be treated by Grasshopper the way it treats all data. Provided you wrote code for it, this type can be baked, previewed, converted into other types, formatted.
It will not be possible however to deserialize the data, as Grasshopper won’t know where to start looking for the class when it is asked to read one of these in from a file.

The problem is that a different script component won’t have access to the same type definition (because it was declared in an assembly it has no references to), and so it cannot convert it into something it can use. This part may work in Python what with the duck-typing, I don’t know.

If you wish to send data from one script component to another, you have the following options in C#:

  1. Use an existing type, for example string. A lot of data could be converted from and to strings, so this allows you to exchange data through regular channels. However it may not be possible in some cases, or may be so involved/expensive that it’s not worth the effort.

  2. Use a framework type which is accessible from both components, for example SortedDictionary<int, byte[]>. Both components have access to the type declaration so casting is no issue. To exchange an instance which does not implement IGH_Goo, you should wrap it up inside a GH_ObjectWrapper. That will prevent Grasshopper from trying to interpret your data and possibly changing it.

  3. Create a dll using Visual Studio which declares the type and reference this dll from both script components. But at this point why not do everything in VS?

  4. Write the data to a file on the disk and only share the file location. The other component then reads the data from the disk. This is a bit of a hack though and leads to potential conflicts or collisions.