TransWikia.com

How to know if the toolshelf/properties/header is ON/OFF with python?

Blender Asked by DB3D on September 29, 2021

i’d like to have a boolean return value with thoses three toggle operator

bpy.ops.view3d.toolshelf()
bpy.ops.view3d.properties()
bpy.ops.screen.header()

id like to toggle them only if they are ‘ON’, but i don’t see any way i can do that

One Answer

there's no official way to know, you can just know, i just found a trick with the interface region width

import bpy

bpy.context.area.ui_type = 'VIEW_3D'
area = bpy.context.area

for region in area.regions:
    if region.type == 'TOOLS':
        if region.width == 1: 
            print("toolshelf closed")
        else:
            print("toolshelf open")
    elif region.type =='UI':
        if region.width == 1: 
            print("properties closed")
        else:
            print("properties open")
    elif region.type =='HEADER':
        if region.width == 1: 
            print("header closed")
        else:
            print("header open")

Answered by DB3D on September 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP