Some operators are global. Some are not. Transform for example is bound to the window where it gets executed in. As an example let's say i want to perform the transform.rotate
from the UV Editor in the UV menu of the 3D view?
All I found so far was some advice in the manual regarding execution context. This example maximizes the screen in all open 3D Views, from: https://docs.blender.org/api/current/bpy.ops.html
# maximize 3d view in all windows
import bpy
for window in bpy.context.window_manager.windows:
screen = window.screen
for area in screen.areas:
if area.type == 'VIEW_3D':
override = {'window': window, 'screen': screen, 'area': area}
bpy.ops.screen.screen_full_area(override)
break
But how would transform.translate
fit in here? I'd like to get a button in 3D View .
To make it a bit more complicated, I don't only want to transform
actually, I'd like to add back the old transform
by 90
degrees back into its location. Which was:
layout.operator("transform.rotate", text="Rotate Minus 90").value = math.pi / -2
Do I still would have to write my own operator here? Or is there an easier way meanwhile?