0
$\begingroup$

I'm creating a Panel that sits in the 3D Viewport. Right now when it runs, it is inserted under the Misc tab. I'd like to create my own tab to place it in. How do I do that?

class NormalToolPropsPanel(bpy.types.Panel):

    """Properties Panel for the Normal Tool on tool shelf"""
    bl_label = "Normal Tool Properties Panel"
    bl_idname = "OBJECT_PT_normal_tool_props"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'

    def draw(self, context):
        layout = self.layout

        scene = context.scene
        settings = scene.my_tool
        
        col = layout.column();
        col.prop(settings, "strength")
        col.prop(settings, "normal_length")
        col.prop(settings, "selected_only")
$\endgroup$
2

1 Answer 1

3
$\begingroup$

Mr batFINGER always has the good stuff, but this should get you started:

import bpy
from bpy.types import Panel


class TestPanel(Panel):
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_label = "Test Panel"
    bl_category = "Test Panel"

    def draw(self, context):
        pass

class TestPanelSub(TestPanel, Panel):
    bl_parent_id = "TestPanel"
    bl_label = "Test Panel Sub Panel"

    def draw(self, context): 

        layout = self.layout

bpy.utils.register_class(TestPanel)
bpy.utils.register_class(TestPanelSub)
$\endgroup$
2
  • $\begingroup$ Thanks, but I'm having a few errors in your code. First I got a warning about 'PT' so I added bl_idname = "OBJECT_PT_test_panel" to TestPanel, then I needed to change TestPanelNew to TestPanelSub. But that's still causing a parent 'TestPanel' not found error. $\endgroup$
    – kitfox
    Commented Jan 26, 2021 at 6:53
  • $\begingroup$ Oops, yeah, changed the name, forgot about the register. I edited the answer, this works for me. (Still complains about PT but doesn't matter) $\endgroup$
    – Psyonic
    Commented Jan 26, 2021 at 7:13

Not the answer you're looking for? Browse other questions tagged .