15
$\begingroup$

I like to keep my scenes clean. Much of my Blender life is spent naming an object, copying the name and pasting the same object name into the mesh data name. Is there a quick way of doing this (or an add-on out there) where I can name a single-user mesh and the mesh data will be replaced with the same name?

$\endgroup$
3
  • $\begingroup$ There's addon which probaly does something similar. $\endgroup$
    – Mr Zak
    Feb 12, 2016 at 19:13
  • $\begingroup$ I already have Name Panel by Proxe, which should do the same thing, but without documentation, I just haven't take the time to figure out how to do that yet. $\endgroup$ Feb 12, 2016 at 19:16
  • $\begingroup$ As I tried it you select objects, Space > Mesh To Object name (unfortunately script doesn't have explanation where to find it in UI but I think Space menu was intended). The downside is that you should remember which command to type. $\endgroup$
    – Mr Zak
    Feb 12, 2016 at 19:18

7 Answers 7

18
$\begingroup$

My answer is a tip rather than a true solution, but it may save your time a bit. Instead of copying and pasting you may just click on the object's icon and drag it to the mesh datablock window.

enter image description here

$\endgroup$
2
  • $\begingroup$ That is slightly faster than hover Ctrl+V then hover Ctrl+P, thanks...I will use that as my new workflow if it is the best answer that comes up. I had no idea you could do that. $\endgroup$ Feb 12, 2016 at 19:12
  • $\begingroup$ Wow that is fantastic, I've been using blender for a few years and never knew about that one, great tip! $\endgroup$ Feb 12, 2016 at 23:33
4
$\begingroup$

This script renames all data instances with one user object to the object's name. Just paste it into the Python console in Blender.

objects = bpy.data.objects
for obj in objects:
  if obj.data and obj.data.users == 1:
    obj.data.name = obj.name
$\endgroup$
3
  • 1
    $\begingroup$ For the simplest of cases this will work fine, for others May or may not work as expected. As mentioned in question needs to be a single user mesh. If any mesh is shared only one mesh will end up with name of object using it, but will be renamed for each. If an empty is selected it will throw an error. Need to narrow down selection accordingly. $\endgroup$
    – batFINGER
    Mar 26, 2020 at 11:16
  • $\begingroup$ I overread the single-user part. I updated the script to only affect meshes that have a single object. $\endgroup$ Mar 27, 2020 at 7:26
  • 1
    $\begingroup$ Would go for if obj.data and obj.data.users == 1: since same applies for curves, armatures etc. $\endgroup$
    – batFINGER
    Mar 27, 2020 at 11:00
3
$\begingroup$

Well I've had the same problem for quite a while, I like keeping my scenes clean and objects well named and always spend considerable amount of time doing so. There are quite a few addons around that make the task easier though.

  1. Name Panel addon is my favorite and combines a name panel on the properties shelf of the 3D view with a fantastic batch renaming tool for renaming and name copying en mass
  2. There is also Batch Rename Datablocks which also works quite well albeit a little simpler.
  3. And also Batch Naming which doesn't copy names but also does batch renaming
$\endgroup$
1
$\begingroup$

I find solution under this post

First, select the objects whose Object Name you would like to copy to the Mesh Data Name. Then use the code below:

import bpy
for obj in bpy.context.selected_objects:
  if obj.type == 'MESH':
    obj.data.name = obj.name
$\endgroup$
1
$\begingroup$

Another good alternative is Simple Renaming Addon

its pretty good, also has a lot of other renaming options enter image description here

$\endgroup$
-1
$\begingroup$

And if you want to change the name through Blender's Python API you can run the following:

bpy.ops.object.select_all(action='DESELECT') # Deselect everything in the scene
bpy.context.scene.objects['oldMeshName'] # Select the mesh whose name is going to change
bpy.context.scene.objects.active.name = 'newMeshName'
bpy.context.scene.objects.active.data.name = 'newMeshName'
$\endgroup$
1
  • 3
    $\begingroup$ One liner: bpy.context.active_object.data.name = bpy.context.active_object.name $\endgroup$
    – brockmann
    Feb 21, 2018 at 11:01
-1
$\begingroup$

a few days ago I had the same issue and came across this post. Realizing that I can't always waste time on manually changing the names of 40+ meshes I decided to make a FREE add-on that adresses the issue.

This add-on allows you to quickly add the _low or _high suffix's to objects name's and datablocks or just copy the object's name to its datablock. All in just 3 buttons! https://gemesil.gumroad.com/l/Easy-Rename-Blender-Addon

Currently I only tested it on versions 2.8 - 3.0 of Blender but it should work just fine on Blender 3.1 as well.

Hope this saves some of you a bit of trouble :D

$\endgroup$
1
  • 1
    $\begingroup$ Maybe it was free before but isnt now. $\endgroup$ Aug 4, 2022 at 5:47

You must log in to answer this question.

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