Skip to main content
2 of 3
added 3933 characters in body

'Scene' object has no attribute my_tool after changing import method from classes to modules in __init__.py

Everything worked until I reworked my import methods to import modules instead of every single class. Now, however, my my_tool call does not work anymore because I can't simply use type=Cabinet_Properties like before. I tried referencing it from the module but am getting an error. No code was changed in the cabinet_panel.py file and it worked before this. How do I make this work again?

In init.py

import bpy, os, sys

PATH = os.path.join(os.path.dirname(__file__),"python_libs")
sys.path.append(PATH)

from .  import test_op
from . import cabinet_panel
from . import properties

#classes = (Test_OT_Operator, CabinetProperties, Test_PT_Panel)

def register():
    """for cls in classes:
        bpy.utils.register_class(cls)
    """
    test_op.register()
    cabinet_panel.register()
    bpy.types.Scene.my_tool = bpy.props.PointerProperty(type = properties.CabinetProperties)

def unregister():
    """for cls in classes:
        bpy.utils.unregister_class(cls)
    """
    test_op.unregister()
    cabinet_panel.unregister()
    del bpy.types.Scene.my_tool

if __name__ == "__main__":
    register()

In cabinet_panel.py

import bpy

class Test_PT_Panel(bpy.types.Panel):
    bl_idname = "Cabinet_PT_Panel"
    bl_label = "Cabinet"
    bl_category = "Archviz Addon"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"

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

        layout.prop(mytool, "cabinetType", expand = True)
        layout.prop(mytool, "cabinetWidth")
        layout.prop(mytool, "cabinetDepth")
        layout.prop(mytool, "cabinetHeight")
        layout.prop(mytool, "flushDoors")
        
        row = layout.row()
        row.operator('view3d.build_cabinet', text = "Built Cabinet")

classes = [
    Test_PT_Panel
]

#register, unregister = bpy.utils.register_classes_factory(classes)

def register():
    for cls in classes:
        bpy.utils.register_class(cls)

def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)

Error message:

TypeError: PointerProperty(...) expected an RNA type, failed with: RuntimeError: , missing bl_rna attribute from 'RNAMetaPropGroup' instance (may not be registered)

Exception in module register(): C:\Users\cayde\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\test_addon_init_.py Traceback (most recent call last): File "c:\Program Files\Blender Foundation\Blender 3.5\3.5\scripts\modules\addon_utils.py", line 369, in enable mod.register() File "C:\Users\cayde\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\test_addon_init_.py", line 29, in register bpy.types.Scene.my_tool = bpy.props.PointerProperty(type = properties.CabinetProperties) ValueError: bpy_struct "Scene" registration error: 'my_tool' PointerProperty could not register (see previous error)

Error: Traceback (most recent call last): File "c:\Program Files\Blender Foundation\Blender 3.5\3.5\scripts\modules\addon_utils.py", line 369, in enable mod.register() File "C:\Users\cayde\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\test_addon_init_.py", line 29, in register bpy.types.Scene.my_tool = bpy.props.PointerProperty(type = properties.CabinetProperties) ValueError: bpy_struct "Scene" registration error: 'my_tool' PointerProperty could not register (see previous error)

Traceback (most recent call last): File "c:\Users\cayde.vscode\extensions\jacqueslucke.blender-development-0.0.18\pythonFiles\include\blender_vscode\operators\addon_update.py", line 27, in execute bpy.ops.preferences.addon_enable(module=self.module_name) File "c:\Program Files\Blender Foundation\Blender 3.5\3.5\scripts\modules\bpy\ops.py", line 113, in call ret = op_call(self.idname_py(), None, kw) RuntimeError: Error: Traceback (most recent call last): File "c:\Program Files\Blender Foundation\Blender 3.5\3.5\scripts\modules\addon_utils.py", line 369, in enable mod.register() File "C:\Users\cayde\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\test_addon_init.py", line 29, in register bpy.types.Scene.my_tool = bpy.props.PointerProperty(type = properties.CabinetProperties) ValueError: bpy_struct "Scene" registration error: 'my_tool' PointerProperty could not register (see previous error)

Sending: {'type': 'enableFailure'}