Opening and closing the N-panel using Blender Python API

Along with the scene objects, the Blender Python API allows us to interact with the Blender interface. For example, using the Python API, we can show and hide the most commonly used toolbar – the N-panel.

For toggling (switching between showing and hiding) N-panels in Blender UI, the wm.context_toggle() operator is used.

The full context data path to the required area is passed in the operator parameter. For the N-panel it will be ‘space_data.show_region_ui’.

To show or hide the N-panel in the current area, we need to call this operator in the simple way:

To hide or show the N-panel in another area, for example in the 3D viewport, we need to override the context to the required area.

Let’s get the 3D viewport area context and call the wm.context_toggle() operator with an overridden context:

The N-Panel will be toggled – opened or closed in the 3D Viewport area.

0 0 votes
Article Rating
Notify of

0 Comment
Inline Feedbacks
View all comments