I ended up using a combination of the two methods: Implementing both the hack to pipe into DrawViewportWires
and the __enter__
/__exit__
methods to add/remove the DrawForeground
method. This means the component still behaves like a “normal” Grasshopper component (i.e. one can turn Preview off to stop drawing etc.).
It seems to work okay so far:
And here’s the minimal case again, with these edits:
201203_DrawRectangle2d_02.gh (5.3 KB)
Thanks again guys, very much appreciated