From 4ffe2fec169c67655aad6a866be3a949b4062108 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Mon, 7 Mar 2022 12:31:36 +0100 Subject: Python: Add new `annotation_pre` & `annotation_post` handlers Annotation tool is used as a general mark tool for many add-ons. To be able to detect when an annotation is done is very handy to integrate the annotation tool in add-ons and other studio workflows. The new callback names are: `annotation_pre` and `annotation_post` Both callbacks are exposed via the Python module `bpy.app.handlers` Example use: ``` import bpy def annotation_starts(gpd): print("Annotation starts") def annotation_done(gpd): print("Annotation done") bpy.app.handlers.annotation_pre.clear() bpy.app.handlers.annotation_pre.append(annotation_starts) bpy.app.handlers.annotation_post.clear() bpy.app.handlers.annotation_post.append(annotation_done) ``` Note: The handlers are called for any annotation tool, including eraser. Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D14221 --- source/blender/blenkernel/BKE_callbacks.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_callbacks.h b/source/blender/blenkernel/BKE_callbacks.h index 66089d29c45..2cd28c4dfa5 100644 --- a/source/blender/blenkernel/BKE_callbacks.h +++ b/source/blender/blenkernel/BKE_callbacks.h @@ -95,6 +95,8 @@ typedef enum { BKE_CB_EVT_LOAD_FACTORY_USERDEF_POST, BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST, BKE_CB_EVT_XR_SESSION_START_PRE, + BKE_CB_EVT_ANNOTATION_PRE, + BKE_CB_EVT_ANNOTATION_POST, BKE_CB_EVT_TOT, } eCbEvent; -- cgit v1.2.3