0

How to close specific area types down using python. Definitely don't want to switch area types, or be jumping in out fullscreen mode?

Close Vertically? or Close Horizontally? Since Blender developers already use the principle, top to bottom, left to right. Then why don't we just start from the top?

enter image description here

Here is a basic example of it working. The above illustration is what should be really focused on though. closing down a middle window.

enter image description here

Any guidance on this would be amazing. Thank you

Adam Earle
  • 23
  • 5
  • 1
    Unless I'm mistaken in blender you can't "close" an area, you have to join it to an existing one. But I dont even know if that's exposed to the API – Gorgious Sep 28 '21 at 20:04
  • 1
    https://blender.stackexchange.com/questions/120479/how-to-join-two-areas-using-python https://blender.stackexchange.com/a/161786/15543 – batFINGER Sep 29 '21 at 17:22
  • https://blender.stackexchange.com/questions/161983/operator-tooltip-from-layout-text – batFINGER Sep 29 '21 at 19:20

1 Answers1

0

i think you need to override context to not close the area in which you are working: here is an example that you can run from Text editor:

import bpy

override_context = bpy.context.copy() area = [area for area in bpy.context.screen.areas if area.type == "NODE_EDITOR"][-1]
override_context['window'] = bpy.context.window override_context['screen'] = bpy.context.screen override_context['area'] = area override_context['region'] = area.regions[-1] override_context['scene'] = bpy.context.scene

areas = [area for area in bpy.context.screen.areas if area.type == "NODE_EDITOR"]

for area in areas: bpy.ops.screen.area_close(override_context)

Tyo 79
  • 31
  • 4