Pack / Conceal Lists for faster exchange between Nodes

Long lists are slow, and there is the ‘trick’ to pack point3d lists in semi-invalid meshes with all the points and only one face. That way you can exchange data between scripted nodes much much faster.

Now - what would be a good way to do the same with arbitrary data? e.g. lists of strings?

My only working approach till now was to write a custom class and copy paste that one in every node, and than move data around inside this custom class, avoiding the lists to be exposed to Gh.

Is there some better way to do that?

thanks!

ok, managed it with Serialization to a memory stream, only with two functions. Gh Definition attached below.

Serialize.gh (4.9 KB)

1 Like

If you want to exchange specific data, you can wrap it up into a GH_ObjectWrapper. This will prevent Grasshopper from trying to interpret the data you assign to outputs. Then, on the other end, you have to cast your object data back into the type you know it should be.

Case in point:

The two C# components exchange a List[List[double]] stashed inside a GH_ObjectWrapper.

gh_objectwrapper.gh (8.8 KB)

thanks alot!