While browsing through the included addons in Blender’s default scripts folder I noticed that a lot of the addons simply register at the bottom like this, with no concern for registering individual classes.
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()
Up until now I had been registering my classes like this:
classes = [myClass, mySuperCoolClass, myOtherClass, someOtherClass]
def register():
for c in classes:
bpy.utils.register_class(c)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
if __name__ == "__main__":
register()
The addons included in Blender certainly declare new classes but just use the module register way of doing things. Trying both ways seems to work, and also I can test run the script from the text editor both ways, and the addon still works. Which way is the best? What’s the difference?