0
$\begingroup$

Newbie. I have a scene with so many objects. I want to rename them at a single time same as their material name. How do I do that? Is there any script/plugin?

$\endgroup$

1 Answer 1

3
$\begingroup$

Name objects after active material

May or may not work as you expect. All objects could share one material and hence renaming would end up with objects named "Material", "Material.001", ... following the blender naming convention for unique object names.

An object can have many materials.

Test script have renamed every object in scene after the name of its active material if it has one.

import bpy from bpy import context from bpy import data # all objects all_objects = data.objects # scene objects scene_objects = context.scene.objects # selected objects selected_objects = context.selected_objects for ob in scene_objects: if ob.active_material: ob.name = ob.active_material.name 

for all objects in blend edit and use

for ob in all_objects: .... 

similarly for selected_objects

$\endgroup$
1
  • $\begingroup$ thank you so much, It worked perfectly what if i want to rename with material's diffuse map/base color (or whatever map used for the color texture) name? for ob in all_objects: if ob.active_material: ob.name = ob.active_material.name.Diffuse_MAP_NAME i meant something like this $\endgroup$ Commented Aug 20, 2020 at 13:17

You must log in to answer this question.