0

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")

kitfox
  • 1,616
  • 5
  • 26
  • 40

1 Answers1

3

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)

Psyonic
  • 2,319
  • 8
  • 13
  • 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. – kitfox Jan 26 '21 at 06:53
  • 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) – Psyonic Jan 26 '21 at 07:13