0
$\begingroup$

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'}
```
$\endgroup$
4
  • $\begingroup$ Hehe, too bad you didn't share the piece of code that would help you solve the problem. Where do you register properties.CabinetProperties ? $\endgroup$
    – Gorgious
    Commented Jun 7, 2023 at 15:25
  • 1
    $\begingroup$ I think you've helped me before so I want to say thank you for that. Once again, I'm an idiot. I never registered it at all! Once I did it worked - thanks so much! $\endgroup$
    – caddev20
    Commented Jun 7, 2023 at 15:35
  • $\begingroup$ hehe yeah everything is more tidy when you put everything in sub modules but you have to remember to link everything correctly. :) btw I suggest you un-register things in the inverse order from which you registered them. It can silence cryptic errors because of dependencies when quitting Blender $\endgroup$
    – Gorgious
    Commented Jun 7, 2023 at 15:53
  • $\begingroup$ Good point - will definitely fix that! $\endgroup$
    – caddev20
    Commented Jun 7, 2023 at 16:37

1 Answer 1

1
$\begingroup$

Needed to register properties.py file.

def register():
    test_op.register()
    cabinet_panel.register()
    properties.register()
    bpy.types.Scene.my_tool = bpy.props.PointerProperty(type = properties.CabinetProperties)

def unregister():
    test_op.unregister()
    cabinet_panel.unregister()
    properties.unregister()
    del bpy.types.Scene.my_tool

if __name__ == "__main__":
    register()
$\endgroup$

You must log in to answer this question.

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