bl_ui_widgets icon indicating copy to clipboard operation
bl_ui_widgets copied to clipboard

Invoke widget when reloading scene

Open gpogorzelski opened this issue 5 years ago • 7 comments

Hi, great tool. Instead of invoking the widget with a key combination I would like for it to happen whenever addon is loaded and I reload a scene. I tried to run it via Operator Search in the gui and by executing bpy.ops.object.dp_ot_draw_operator('EXEC_DEFAULT') in a persistent handler that I add in the register method - no success there. Any ideas? Thanks

gpogorzelski avatar Nov 19 '20 20:11 gpogorzelski

Hi, checkout these handlers https://docs.blender.org/api/current/bpy.app.handlers.html

Best regards Jayanam

On Thu, Nov 19, 2020 at 9:38 PM gpogorzelski [email protected] wrote:

Hi, great tool. Instead of invoking the widget with a key combination I would like for it to happen whenever addon is loaded and I reload a scene. I tried to run it via Operator Search in the gui and by executing bpy.ops.object.dp_ot_draw_operator('EXEC_DEFAULT') in a persistent handler that I add in the register method. Any ideas? Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jayanam/bl_ui_widgets/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJUGIF4MUM6F73WEPIX2PDSQV64JANCNFSM4T34V72Q .

jayanam avatar Nov 19 '20 21:11 jayanam

Hi, thanks for the answer but unfortunately when I call bpy.ops.object.dp_ot_draw_operator('EXEC_DEFAULT') in a persistent handler as in the documentation link you providede it doesn't work.

gpogorzelski avatar Nov 20 '20 09:11 gpogorzelski

Could you send your code?

On Fri, Nov 20, 2020 at 10:03 AM gpogorzelski [email protected] wrote:

Hi, thanks for the answer but unfortunately when I call bpy.ops.object.dp_ot_draw_operator('EXEC_DEFAULT') in a persistent handler as in the documentation link you providede it doesn't work.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jayanam/bl_ui_widgets/issues/6#issuecomment-731039507, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJUGIDOYCFYLATCVQFUYHLSQYWHNANCNFSM4T34V72Q .

jayanam avatar Nov 20 '20 09:11 jayanam

And did you try "INVOKE_DEFAULT"

On Fri, Nov 20, 2020 at 10:10 AM Jayanam [email protected] wrote:

Could you send your code?

On Fri, Nov 20, 2020 at 10:03 AM gpogorzelski [email protected] wrote:

Hi, thanks for the answer but unfortunately when I call bpy.ops.object.dp_ot_draw_operator('EXEC_DEFAULT') in a persistent handler as in the documentation link you providede it doesn't work.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jayanam/bl_ui_widgets/issues/6#issuecomment-731039507, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJUGIDOYCFYLATCVQFUYHLSQYWHNANCNFSM4T34V72Q .

jayanam avatar Nov 20 '20 09:11 jayanam

Hi, please find a minimal working example here: https://github.com/gpogorzelski/reload_scene_blender.git I create a new dir in the addons dir and then copy it all there followed by addon install in blender and then simply start it with ctrl+shift+k. First button spawns the table, the second deletes all objects and reloads a scene (so you have to save a scene before pressing it). After the reload the widget does not appear.

And yes I did try INVOKE_DEFAULT. Still no success

gpogorzelski avatar Nov 20 '20 09:11 gpogorzelski

Also, how would you change the value of the text label in the DP_OT_draw_operator, from outside of the class? Say I want to change the label to the number of the currently displayed frame, how would I access the operator instance and its members?

gpogorzelski avatar Nov 20 '20 15:11 gpogorzelski

An operator can have properties that you can define and change. https://blender.stackexchange.com/questions/60422/access-operators-property-with-python

On Fri, Nov 20, 2020 at 4:58 PM gpogorzelski [email protected] wrote:

Also, how would you change the value of the text label in the DP_OT_draw_operator, from outside of the class? Say I want to change the label to the number of the currently displayed frame, how would I access the operator instance and its members?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jayanam/bl_ui_widgets/issues/6#issuecomment-731252186, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJUGIBBBPFR5CKP3NTSEZDSQ2GY7ANCNFSM4T34V72Q .

jayanam avatar Nov 20 '20 16:11 jayanam