Hey guys
I have a question about bpy.context.
A quick background to my problem: I have a PySide2 gui, which I am starting in Blender. I want to run some operators from it, which often require a certain context. Of course Blender does not know what the current bpy.context is from my PySide2 Gui.
I already found out, as nicely explained here:
https://docs.blender.org/api/current/bpy.ops.html
that you can override the context in which an operator is running by passing a dictionary as the first argument.
This way I got the operator bpy.ops.wm.alembic_export() running from my PySide2 Gui. It even works on my current selection. It was enough to just run the operator in the 3DViewport by passing a dictionary with the following keys:
override = {‘window’: window, ‘screen’: screen, ‘area’: area}. (As explained in the link, on how to run an operator in a specific window)
While this is all working fine by now I am still interested in a couple of things:
A) Is there a way to get the current selected objects without having a suitable current context available? (via bpy.data ? via an operator that is running in another window?)
B) Is there a way to pretend to be in a ceratin context, for example the one of the 3DVIEW for actions that don’t support the overriding of context?
Thanks guys and I hope you can somehow enjoy a cozy christmas!