2
$\begingroup$

Similar to this post:
How to make the sequencer 'Preview' area fullscreen with python?

I am trying to have my script set the animation preview window to fullscreen without any other panels/menus:

Blender V2.8 Animation Layout

I'm trying to figure out how to navigate the hierarchy of screens, areas, and workspaces and set just that panel on the 'Animation' properly. I'm often getting 'context is incorrect' run time errors or an error trying to set read-only object.

My script changes to the Animation screen:

# animation view
bpy.context.window.workspace = bpy.data.workspaces['Animation']

Changes the shading to rendered:

for area in bpy.data.screens['Animation'].areas:
    for space in area.spaces:
        if space.type == 'VIEW_3D':
            space.shading.type = 'RENDERED'

And then tries to changes the screen to fullscreen:

# full screen
bpy.ops.screen.screen_full_area(use_hide_panels=True)

But, the panel does not go full screen unless I do it manually via the GUI.

I'm hoping there's a way to achieve this similar to the sequencer preview full screen example that will work on the animation preview window.

Adding an completely separate view - without affecting the existing 'Animation' would be even better.

UPDATE: Thanks @rjg for your involvement. Now, when the animation runs (via script that kicks off the full-screen animation preview window) the objects are animating but the textures/images are blank:

not rendered during animation via script

I'm using:

bpy.context.scene.frame_set(f)
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)

To do the animation playback after going full screen.

$\endgroup$
3
  • $\begingroup$ Have you checked that you're still in rendered mode and that the texture appears when switching into rendered mode without fullscreen? $\endgroup$
    – Robert Gützkow
    Oct 3, 2019 at 20:12
  • $\begingroup$ @rjg - "still in rendered mode"... yes. The blender file starts off basically blank. The script imports an image, animates it, deletes the image and keeps repeating until there are no more images. Possibly a blender bug as I've had weird issues after running this several times (e.g. "builtin select_box not found") $\endgroup$
    – Jay Marm
    Oct 4, 2019 at 3:40
  • $\begingroup$ Then there's probably a bug in your code in the way you load and assign the image texture. It's best to add a new question for this problem. $\endgroup$
    – Robert Gützkow
    Oct 4, 2019 at 12:21

1 Answer 1

3
+50
$\begingroup$

There are two things necessary to set the fullscreen mode successfully:

  1. Wait for the workspace to be switched
  2. Create a custom context for the operator

The first part can be accomplished by adding an application handler that is triggered after the dependency graph is updated. The second part is necessary to set the correct area to fullscreen. This can be solved by iterating through the areas of the current screen to find VIEW_3D.

You can leave the fullscreen mode by pressing CTRL + ALT + SPACE.

import bpy

# Press CTRL + ALT + SPACE to leave fullscreen mode 
def view3d_fullscreen(dummy):
    bpy.app.handlers.depsgraph_update_post.remove(view3d_fullscreen)
    context = bpy.context.copy()

    for area in bpy.context.screen.areas:
        if area.type == 'VIEW_3D':
            for space in area.spaces:
                if space.type == 'VIEW_3D':
                    space.shading.type = 'RENDERED'
            context['area'] = area
            bpy.ops.screen.screen_full_area(context, use_hide_panels=True)
            break

bpy.app.handlers.depsgraph_update_post.append(view3d_fullscreen)
bpy.context.window.workspace = bpy.data.workspaces['Animation']
$\endgroup$
1
  • 1
    $\begingroup$ If you attempt to switch to fullscreen with a custom context without waiting for the dependency graph changes it will result in a crash, because the v3d pointer will be NULL. $\endgroup$
    – Robert Gützkow
    Oct 3, 2019 at 14:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .