How to hide panels with python? I want to make quick hiding for better viewing.
Here is what I want to hide:
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
Currently the Python API can't handle opening and closing panels (it's not exposed).
The only thing you can do with python is to toggle by calling operators:
They need the right context though, so they need to be called from the 3dview area or the context needs to be overwritten. This will toggle all panels in all 3d_views inside window:
for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': context_copy = bpy.context.copy() context_copy['area'] = area bpy.ops.view3d.properties(context_copy) bpy.ops.view3d.toolshelf(context_copy)
Here is a way to check if they are currently open, you simply test how wide they are, also suggest storing a variable if you intend to untoggle it "toggle_properties = True" for a modal so you don't have to test again.
# hide 'T' and 'N' panels for r in bpy.context.area.regions: if r.type == 'UI': if r.width > 1: bpy.ops.view3d.properties() toggle_properties = True elif r.type == 'TOOLS': if r.width > 1: bpy.ops.view3d.toolshelf() toggle_tools = True