diegogarciahuerta / tk-blender

:milk_glass: Shotgun Toolkit Engine for Blender: https://www.blender.org/
Other
44 stars 33 forks source link

bpy.context is lacking when calling from a Qt window #4

Open MoisMoshev opened 3 years ago

MoisMoshev commented 3 years ago

When operating from a Qt window, it seems that bpy.context does not know the current area, camera, etc.

To Reproduce Steps to reproduce the behavior:

  1. Open a Qt window with a button to call op that needs the current context
  2. Click the button to execute the app
  3. See that bpy.context.area, bpy.context.camera etc. are empty, although the currently selected area in blender is the correct view.

I wonder whether there is a canonical way to get to the original context.

MoisMoshev commented 3 years ago

I did some more digging, and found that the context is available before the menu opens, and not available afterwards. (which I should probably have expected). Would you be interested in a PR that remembers the current bpy.context before opening the menu? i.e. as a property on the engine or so. Then it will be cleared when the menu/windows close.

Currently I see no better alternative.

andreasmalta1 commented 2 years ago

Have you find a way around this ? It's proving to be a problem when trying to do the following: bpy.ops.sequencer.image_strip_add()