As suggested by @diff-arch above, you can likely simplify/better manage things by also recording the data using GHPython. Here’s some examples demonstrating the basic ingredients you’d need:
Edit: Ah, sorry. You were posting a solution, need more coffee