Hello dear blender community,
I am trying to automate a few tasks in Blender, and trigger their execution from the command line like this:
blender %file% --python myScript.py
. My script is calling an installed Addon developed by someone else. This addon is calling at several points in the code bpy.context.area
to set the context for some bpy.ops.
operators.
This is were my struggles start. As I am calling blender from the CMD without the --background
argument, I (possibly falsely) assumed that the context and ops are unaffected, sadly though I cannot force blender to set a bpy.context.area
.
I tried to set a context using this:
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 it fails on setting an area, and bpy.context.area
remained a NoneType.
Is there a way I can call blender from CMD, let it first draw a GUI and only call my script headlessly once the bpy.context.area
is no longer a NoneType?
I tried naively a time.sleep
statement, and tried different ways of setting a context to one of the areas from bpy.data.screens['xx'].areas[0]
, but failed so far.
Does anyone have a CLI argument or a snippet I can add to my code to create a bpy.context.area
?
I am running Windows and Blender 2.93.1.
Many thanks!!