Object homogenizer

This is a very simple script designed for organizing simple blend files.

In my case I am building a library of props. Each Object has one mesh and one material (it’s for game engine use, so it’s simple).

Running the Object Homogenizer takes the object name and set’s the mesh and material names to match. This may result in some weird names if objects share materials or meshes, so it’s best used on libraries.
You can limit it by making some objects unselectable (from the organizer).

So if you start with:
Object Name = Shield Generator
Mesh Name = Cube.001
Material Name = Material.003

You’ll end up with:
Object Name = Shield Generator
Mesh Name = Shield Generator
Material Name = Shield Generator

At some stage I may add in texture renaming, but some objects have multiple textures, and textures are often shared.

Here’s the script. Just copy-paste to the text editor and hit alt+p

renameMesh = True
renameMaterial = True

import bpy

for obj in bpy.context.selectable_objects:
    if obj.type == 'MESH':
        if renameMesh == True:
            obj.data.name = obj.name
        if renameMaterial == True and len(obj.material_slots) == 1:
            obj.active_material.name = obj.name    

For info there is also the Batch Rename addon (tested with blender 2.65a) http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Object/Batch_Rename_Datablocks