Hey, I hope someone has an idea as to whats going on because this has been throwing me off for a while.
Ive been moving plugin code off the Toolshelf in the 3D view since Blender 2.8’s UI design has changed, and some of my operations now reside in the Render menu. As they rely on a 3D View being the current context to operate within it for certain tasks, I have to switch the context area. However, doing a translate operation once changed causes Blender to crash and I haven’t been able to work out why as the crash logs provide little useful information.
I’ve included a basic addon you can add to Blender to test it yourself, the button will appear under the Render menu in the Properties panel.
Looks like a bug with blender trying to access a freed region. Passing any arbitrary region from a different area in the override seems to be fine.
import bpy
context = bpy.context
for area in context.screen.areas:
if area != context.area:
break
override = {'region': area.regions[0]}
context.area.type = 'VIEW_3D'
bpy.ops.transform.translate(override)
Thanks for the help, i’m unable to get your override suggestion working though - there’s no override parameter for the operator. I’m also not sure what the purpose of the break is…
Override arguments are implied when operators are called with the first positional argument as a dictionary. If you need to pass other arguments, the order is context_dict >> exec_type >>**kwargs.
To break is to stop looping. When the conditional evaluates to true I exit the loop with the area using break. The idea is to get an area that is notcontext.area, since that one has a faulty region.