I would like to know how reference a Class created in a separate Python file. I'm working on an add-on that will let people create custom models using designs I've sculpted. I have a custom UI with buttons that let you choose which models to import and what to do with them. However, I would like to add new models in the future, which would require adding new stl's to the same directory. More importantly, this would mean the UI would need to be updated with new buttons and check marks. Here is the main panel I created. Each of those operators are different models that can be imported.
class BaseCreator(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Base Creator"
bl_idname = "Base_Creator"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Base Creator'
def draw(self, context):
layout = self.layout
row = layout.row()
layout.operator("dungeon.tile")
row = layout.row()
layout.operator("initialize.scene")
row = layout.row()
layout.operator("terrain_import.rocks")
row = layout.row()
layout.operator("terrain_import.stone")
row = layout.row()
layout.operator("terrain_import.sand")
row = layout.row()
layout.operator("terrain_import.seals")
row = layout.row()
layout.operator("terrain_import.industrial")
row = layout.row()
layout.operator("change.terrain")
row = layout.row()
layout.operator("add.assets")
layout.operator("terrain.combine")
I would like to place this in a separate python file whose name will always be the same (let's say "MyUI.py") and lives in the same directory as the models that can be imported. How would I would I pull in this class in the main code? I know I'll have to import it, but how do I reference the class so that it creates the panel when I run the main script? Do I place the whole class in a separate python file, register it there and then just import that when the main code starts? Or do I leave the class where it is and just place the draw function in a separate file?
I've managed to put variables like lists of asset names in a separate file and call them successfully, but I'm not totally sure how to call a class from a separate python file and make it create the panel successfully. Any help would be appreciated!