1
$\begingroup$

First time posting here so excuse me if there is an issue with this question.

I have been writing a custom UI addon for blender I have taken out the majority of the code and hopefully kept it as clean as possible to replicate this warning. I often use the console window for debugging and when I am using my plugin the following warning is constantly spammed:

unable to get Python class for RNA struct 'MAIN_PT_Mainpanel

The simplified code that produces this error is as below:

import bpy
import numpy as np
import mathutils as m
import math
import os


bl_info = {
    "name": "Generation tool",
    "description": "",
    "author": "",
    "version": (0, 0, 4),
    "blender": (2, 80, 0),
    "location": "3D View > Tools",
    "warning": "",  # used for warning icon and text in addons panel
    "wiki_url": "",
    "tracker_url": "",
    "category": "Development"
}

from bpy.props import (StringProperty,
                       BoolProperty,
                       IntProperty,
                       FloatProperty,
                       FloatVectorProperty,
                       EnumProperty,
                       PointerProperty,
                       CollectionProperty
                       )
from bpy.types import (Panel,
                       Menu,
                       Operator,
                       PropertyGroup,
                       )

# ------------------------------------------------------------------------
#    Scene Properties
# ------------------------------------------------------------------------

class MyProperties(PropertyGroup):

    sample_rate: IntProperty(
        name="Samples",
        default=500
    )

# ------------------------------------------------------------------------
#    Panel in Object Mode
# ------------------------------------------------------------------------

class Main_panel(Panel):
    bl_label = "Generation Settings"
    bl_idname = "MAIN_PT_Mainpanel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "Generation"
    bl_context = "objectmode"
    @classmethod
    def poll(self, context):
        return context.scene is not None
    def draw(self, context):
        layout = self.layout

class General_sett_subpanel(Main_panel, bpy.types.Panel):
    bl_idname = "SUB_PT_Gensett"
    bl_label = "General Settings"
    bl_parent_id = "MAIN_PT_Mainpanel"

    def draw(self, context):
        layout = self.layout
        scene = context.scene
        mytool = scene.my_tool

        layout.prop(mytool, "sample_rate")

# ------------------------------------------------------------------------
#    Registration
# ------------------------------------------------------------------------

classes = (
    MyProperties,
    Main_panel,
    General_sett_subpanel
)

def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)
    bpy.types.Scene.my_tool = PointerProperty(type=MyProperties)

def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)
    del bpy.types.Scene.my_tool


if __name__ == "__main__":
    register()

I would appreciate any help you can offer me. Thanks in advance!

$\endgroup$
0

1 Answer 1

2
$\begingroup$

I've coded a fair amount of scripts that use Blender's layout api, but i've never ventured into subpanels. So i may be misunderstanding the intent here.

try

class General_sett_subpanel(bpy.types.Panel):
    bl_idname = "SUB_PT_Gensett"
    bl_label = "General Settings"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_parent_id = "MAIN_PT_Mainpanel"

notice this drops the inheritance of the Mainpanel, but forces you to add bl_space_type and bl_region_type explicitly. I'm not sure it made sense to inherit Mainpanel, the Mainpanel's poll function will determin if the subpanel is displayed anyway.

either way, this does suppress the warning.

$\endgroup$
2

You must log in to answer this question.

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