In my addon, I need to do a bunch of stuff while running modal. One of those things is drawing with a grease pencil, and then processing the curve. By grease pencil, I mean just the simple annotation tool.
However, I am not able to get the grease pencil to draw from modal. If I call my draw_curve() function defined below from a button, it works fine. But from modal, the cursor does not become a pencil, and I cannot draw. What am I missing?
(I guess it might have something to do with detecting the left mouse press to actually commence drawing a stroke, but this worked in modal in Blender 2.7x without any further steps, and I’m having trouble figuring out what else 2.8 wants.)
Thank you Cirno! Passing ‘INVOKE_DEFAULT’ to gpencil.annotate() is the solution.
Unfortunately, this doesn’t allow the left mouse release to pass through to the modal, in order to automatically be able to run operations on the generated grease pencil stroke. Is there any way to be able to detect this left mouse release, at the end of a single grease pencil stroke?
(In 2.7x I never figured out this followup question out, so my users have to move the mouse after the left mouse release in order to initiate further processing, but this seems clumsy.)
I think you can’t, you need to use a macro operator. Here’s an example, save the code as .py and install as addon. To initialize the modal press ctrl+alt+shift+g. Draw with LMB, annotation stroke should be converted to grease pencil object on the left mouse release