Enable addon fails mod.register()

This is the first addon I create for blender and thus struggling a bit with getting it to work properly with blender. When I try to enable the addon I get the error you can see in a screenshot below.


I don’t understand the error, have I missed to register something that I should have registered? I don’t think so.

/GB

Please post your code (in code tags).

The (de-)registration code should look somewhat like this:

def register():
    bpy.utils.register_module(__name__)

def unregister():
    bpy.utils.unregister_module(__name__)

if __name__ == '__main__':
    register()

Hmm, I did it like this:


def register(class_name):    
    bpy.utils.register_class(class_name)


def unregister(class_name):
    bpy.utils.unregister_class(class_name)


def register_class(class_name):
    if __name__ == '__main__':
        register(class_name)


register_class(WireframePanel)
register_class(WireframeOperator)
register_class(ClearWireframesOperator)
register_class(SelectLayersAffectedOperator)
register_class(SelectLayersOtherOperator)
register_class(DeselectLayersAffectedOperator)
register_class(DeselectLayersOtherOperator)
register_class(ErrorMsg)

This is how I learned the way of registering, but why would you do like this if you can register it all at once with the way you did now? Anyways, is there any problem in my code?

Your code is quite obscure, no need to do that many functions and calls… plus it won’t work like that. register() is called by your own code, but unregister() is expected and called by Blender, with no arguments.

Forget about register_class and use my code above instead, it’s all you will ever need. register_module() will automatically register all your classes.

Thanks a lot! Works like a charm now. :wink: