jayanam / bl_ui_widgets

UI Widgets for Blender 2.8
GNU General Public License v3.0
150 stars 38 forks source link

Invoke widget when reloading scene #6

Open gpogorzelski opened 3 years ago

gpogorzelski commented 3 years ago

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

jayanam commented 3 years ago

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 notifications@github.com 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 .

gpogorzelski commented 3 years ago

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.

jayanam commented 3 years ago

Could you send your code?

On Fri, Nov 20, 2020 at 10:03 AM gpogorzelski notifications@github.com 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 commented 3 years ago

And did you try "INVOKE_DEFAULT"

On Fri, Nov 20, 2020 at 10:10 AM Jayanam jayanam.games@gmail.com wrote:

Could you send your code?

On Fri, Nov 20, 2020 at 10:03 AM gpogorzelski notifications@github.com 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 .

gpogorzelski commented 3 years ago

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 commented 3 years ago

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?

jayanam commented 3 years ago

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 notifications@github.com 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 .