Failed script causing Addon window blank and help with the script

Hi,

As a training, I was trying to create a simple add-on that snaps selected objects to the position of the active one. It worked as as script but when I tried to turn it into an addon (adding the bl_info ={ …} line at the beginning of the script) I got errors when I tried to ‘Install it from files’


and now the Addon window is completely empty.


I’ve tried to refresh it, even restarted my computer and reopening Blender but it does nothing.

It’s strange because addons already installed are still working.

Any idea what can cause that and what the problem is in my script ? I knew it was probably unfinished (especially, I wasn’t sure what to write exactly in bl_info) but I wasn’t expecting such a strange consequence. My plan was to install it then create later a hotkey in the Input window of the user preferences to call it.

I might as well reinstall Blender (there’s a ‘b’ version of the 2.72 that has just arrived) but I’m not sure how to do it without losing all my preferences.

Thanks !



bl_info = {
    "name": "Snap to Active",
    "author": "Stef Rig",
    "version": (0, 5),
    "blender": (2, 72, 0),
    #"location": "View3D > Add > Mesh > New Object",
    "description": "Snap selected objects to active object",
    "warning": "",
    "wiki_url": "",
    "category": "Object"
    }
    
import bpy

C = bpy.context
   
def snap_to_active (context) :
    
    # Tests if there's at least one selected object
    if len(C.selected_objects) > 0 :
             
        for sel in C.selected_objects :
            sel.location=C.object.location # selected objects location sets to active object location
 
            
class SnapToActive (bpy.types.Operator) :
    '''Snap position of selected objects to position of active object
    '''
    
    bl_idname = "object.snap_to_active"
    bl_label = "Snap to active"
    bl_options = {'UNDO', 'REGISTER'}
    
    def execute (self, context) :
        snap_to_active (context)
        return {'FINISHED'}
    
def register ():
    bpy.utils.register_class(SnapToActive)

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

if __name__ == "__main__" :
    register ()


EDIT : wrong forum, I wanted to post it in the python support forum… can a moderator move it there ? Thanks.
(and does anyone know how I can remove the big image attached at the end of the post ? it’s an old version of one of the image, I haven’t found the ‘remove’ option in the ‘attached management’ window when editing my message, is it possible ?)

Attachments