Rather than have 10,000 class names in an array in my __intit__.py
, I want to have separate modules for each.
Here’s what I’m working with:
array_alpha.py
import bpy
array_alpha_classes = [
Alpha_Panel,
Alpha_Class_01,
Alpha_Class_02,
Alpha_Class_03,
]
All other class definitions are in separate files.
__init__.py
bl_info = {}
import os
import bpy
from .color_sets.colors_alpha import *
from .color_sets.colors_internal import *
from .panels.panel_alpha import *
from .panels.panel_internal import *
from .array_alpha import *
array_internal_classes = [
Internal_Panel,
Internal_Class_01,
Internal_Class_02,
Internal_Class_03,
]
classes = [
*array_internal_classes,
*array_alpha_classes
]
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
if __name__ == "__main__":
__file__ = bpy.data.filepath
register()
But when I I run it, the error I get is
Traceback (most recent call last):
File "/Applications/Blender.app/Contents/Resources/3.2/scripts/modules/addon_utils.py", line 335, in enable
mod = __import__(module_name)
File "/XXX/Blender/3.2/scripts/addons/sample_addon/__init__.py", line 100, in <module>
from .array_alpha import *
File "/XXX/Blender/3.2/scripts/addons/sample_addon/array_alpha.py", line 4, in <module>
Alpha_Panel,
NameError: name 'Alpha_Panel' is not defined
So the array items in array_alpha.py
needs to be defined, but how?
Any suggestions?