Script to Toggle Fullscreen Area (Blender 2.8)

Hey there,
I am working on a script to automatically take screenshots of a dataset of .stl meshes and I’d like to have only the .stl object framed, that is with all menus, tools and other buttons hidden. The result I am trying to achieve with a script can be reproduced with the CTRL + ALT + Space keyboard shortcut in the UI.
This has already been discussed here, although it’s not working as desired for me. I have adapted the script so it works on Blender 2.8 as explained here, to no avail.
Could anyone help?

1 Like

Solved. What I was looking for was really close to the issue discussed in this post.
Here’s the code snippet that does the work:

import bpy

context = bpy.context.copy()

for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        context['area'] = area
        bpy.ops.screen.screen_full_area(context, use_hide_panels=True)
        bpy.context.space_data.show_gizmo = False
        bpy.context.space_data.overlay.show_overlays = False

Hope it can be of some help to others!