User draw polyline on grasshopper Mesh in Rhino Viewport

Hi everyone, I need users to draw Polylines on a GH-Mesh Preview in the Rhino-Viewport which are then used as Input for the rest of the Script.
I’m not sure how to even approach this problem.

So far I used HumanUI to set up a button to trigger a c# Component that:

  • bakes a mesh to Rhino,
  • runs the “_Polyline persistentonmesh” Command via RhinoApp.RunScript,
  • gets the Polyline outcome and adds it to a List of drawn Polylines,
  • purges the mesh and Polyline from Rhino,
  • outputs the updated List of Polylines.

This is pretty hacky though because:

  • The preview of the mesh in the viewport is pretty different from the Grasshopper “Custom Preview” that I use to show the results of the Script
  • Grasshopper freezes during the Command
  • Script-results (Meshes) stop showing because GH is frozen
  • Polylines stop outputting during the command

Is there a better way to do this?