[Add-on] Replace object name with mesh name on all selected objects

I released a script a few days ago that allows you to have the mesh names matched to the object name on all selected objects. This script is exactly the same, but does the opposite. For every selected mesh, it replaces the objects name with the mesh name.

Install like any other add-on.
Select objects -> Space -> Mesh to object name

Easy!
Download

why not have them in a single add-on?

:slight_smile:


bl_info = {
    "name": "Object to mesh name",
    "category": "Object",
}



import bpy

class ObjectToMeshName(bpy.types.Operator):
    """Object to mesh name"""      
    bl_idname = "object.objecttomeshname"        
    bl_label = "Object to mesh name"         
    bl_options = {'REGISTER', 'UNDO'}  

    def execute(self, context):        

        scene = context.scene
        for obj in bpy.context.selected_objects:
            if obj.type == 'MESH':            
                obj.data.name = obj.name    
                  
        return {'FINISHED'}            


class CopyMenu(bpy.types.Menu):
    bl_label = "Copy"
    bl_idname = "OBJECT_MT_copyname_menu"

    def draw(self, context):
        layout = self.layout

        layout.operator("object.objecttomeshname", "", icon="PASTEDOWN") 
        #layout.operator("object.meshnametobject", "", icon="PASTEUP") 


def draw_item(self, context):
    layout = self.layout
    layout.menu("OBJECT_MT_copyname_menu")


        
def register():
    bpy.utils.register_module(__name__)
    
    bpy.types.OUTLINER_HT_header.prepend(draw_item)
          
def unregister():
    bpy.utils.unregister_module(__name__)
    
    bpy.types.OUTLINER_HT_header.remove(draw_item)
    
if __name__ == "__main__":
    register()

@Albertofx: I’m afraid I’m pretty new to making add-ons so I only know how to make basic add-ons without buttons etc at the moment.

@mkbreuer: Is that what I think it is? :slight_smile:

cypher2012 . Thanks! Very useful, I’, really bugged by how Blender does not rename both automatically. Really makes a mess when exporting OBJ. Oh well, community to the rescue!

mkbreuer . Thanks on adding it to the Outliner File Menu, much appreciated!!

If you haven’t spotted it yet, I created an add-on to help with all your naming needs, link is in my signature, just trying to increase awareness and limit duplicate efforts.