I'm converting voxel art to blender for animation and render. All the cubes import automatically named cube.001, cube.002, ect. I then parent all those cubes to an empty to animate their movement and name the empty what ever the object is. only problem is when I import new objects even from other blender scenes, the imported cubes rename themselves so that they aren't duplicating names, so cube.001 becomes cube.234 and so on. Problem is that my friend is talking about potentially building a video game with these assets so accidentally renaming objects like this could be problematic in the future. Is there a way to rename all the children objects so they have a prefix that matches the parent name? For example parent: "space-bug" would rename the cubes "space-bug-cube.001" and so on.

  • $\begingroup$ Try this: create new mesh (which has vertices, other than empty like circle or any thing) and name it. Select all objects and last select the new mesh with the name and press Cltr+J to merge into single object. Then go into edit mode and select all vertices and press P-> separate by loose parts. Now the objects have .001 ,.002... with name given to new mesh. It may work. $\endgroup$
    – Feenix
    Nov 19, 2018 at 4:04

2 Answers 2

import bpy

current_object = bpy.data.objects
i = 0
for ob in bpy.context.scene.objects:
    # check if parent exist
    existing_parent = current_object[ob.name].parent
    if existing_parent:
        # check if it has been already renamed from parent
        if not current_object[ob.name].parent.name == current_object[ob.name].name.split('.')[0]:
        # change the name of the object to the name of parent
            current_object[ob.name].name = existing_parent.name + '_' + str(i).zfill(2)
            print(ob.name, existing_parent.name)
            i += 1
            print('nothing to do')

this script renames the objects in the scene according to their parent. if they share already the same name (meaning probably it has been already renamed) it does nothing. far from by polished though as for know it adds a numerical sequence to all the scene not per object.

enter image description here


Found a solution using an add-on that batch renames all selected objects when you hit ctrl+r.



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .