9
$\begingroup$

If we have modeled a character or device or something that has many identical moving parts (arms, tentacles, etc.), and rigged one instance of such a part, how do we get all of the bones with the same names joined as a single armature, and also get all of the meshes joined with the vertex groups that correspond to those bones?

Bone and vertex group batch renaming - an illustration of the problem

In the example above, the character has only six legs (the wrong number for an octopus, just to add to the poor guy's problems), but what about something with even more appendages, like a centipede? What about a spider robot with very complex leg rigs? In cases like these nobody wants to go renaming each bone by hand, and then renaming each vertex group by hand.

So, we need an add-on or a Python script for batch renaming. The only add-on I've found for batch renaming is too simplistic - just for renaming at the object level. And although I found and tried a script for renaming bones, I got an error when I ran it. I also found a script for renaming vertex groups, but I haven't found any scripts that handle the mesh and armature data together.

What is the most efficient way to accomplish this?

$\endgroup$

3 Answers 3

5
$\begingroup$

Usually an armature is the parent of the mesh that it deforms (from using ⎈ CtrlP->Automatic Weights), this means we can get the mesh deformed by the armature by looking at it's children property. We can then rename both the bone and vertex group to a new name that is unique among all armatures allowing a conflict free merge. Adding the rig name to the bone name so that "Bone" might become "Leg1_rig_Bone" seems like a good approach.

import bpy

for rig in bpy.context.selected_objects:
    if rig.type == 'ARMATURE':
        for mesh in rig.children:
            for vg in mesh.vertex_groups:
                new_name = rig.name + '_' + vg.name
                rig.pose.bones[vg.name].name = new_name
                vg.name = new_name
$\endgroup$
1
  • $\begingroup$ This works perfectly! It's exactly what I needed. You're a genius. Thank you so much. $\endgroup$
    – Mentalist
    Commented Jun 10, 2017 at 18:26
1
$\begingroup$

Have you looked into the Name Panel Addon?

It's a payed commercial addon, but it is open source, hosted on GitHub and you can also buy it from the Blender Market if you wish to show support for the developer.

It is quite a versatile extension, with capable batch renaming functions for objects, materials textures, groups etc.

It also has good batch name copy/transfer and additional UI features for selection and filtering.

Among that it also includes an advanced bone renaming feature, including armatures, bones and constraints and automatic name generator.

Disclaimer: I am not in any way affiliated with the addon author or product, although I do am a happy customer.

$\endgroup$
3
  • 1
    $\begingroup$ Thanks. This looks really useful, and I may purchase it for myself. However, I'm mainly asking this question on behalf of someone who asked me. So I would like to offer a solution to them without telling them they need to buy something extra. I'd still like to know if there is a way to rename rig data for free with a script, even if it's not as full-featured as the add-on. $\endgroup$
    – Mentalist
    Commented Jun 9, 2017 at 22:19
  • $\begingroup$ Well you could theoretically get it for free from the github repo, if you are so inclined, other than this I am not aware of any other method, though I confess rigging it is not something I do at all. I know a couple of other free naming addons, but I don't think they do armature renaming as far as I know Batch Namer and Batch Rename Datablocks $\endgroup$ Commented Jun 9, 2017 at 22:27
  • $\begingroup$ This addon appears to have fallen off of the internet completely. $\endgroup$
    – Kirbinator
    Commented Feb 16, 2022 at 20:18
0
$\begingroup$

Go to Edit menu then choose Batch Rename or press Ctrl + F2.

$\endgroup$
1
  • $\begingroup$ Hi, thanks for the post. This site is not a regular forum, answers should be substantial and thoroughly explain the solution and required workflow. One liners and short tips rarely make for a good answer. If you can edit your post and provide some more details about the procedure and why it works feel free to restore it, otherwise it may be deleted or converted into a comment. Perhaps add a few images illustrating the workflow and final results. See How do I write a good answer? $\endgroup$ Commented Nov 15, 2021 at 11:38

You must log in to answer this question.

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