1
$\begingroup$

I have a model with a lot of vertex groups. I've found out that I'm missing one, or need to add one for a new reason, or whatever. However, to keep the list usefully organized, the new group should be near the beginning of the list. The problem is that all new vertex groups are added at the end of the list, and it seems that the only way to reorder them is to click on the "move up" button once per spot. I don't really want to be clicking the "move up" button a couple dozen times, especially if it turns out I need to (for example) add four new groups that all belong near the beginning of a sixty-long list for a couple dozen models.

How can I move a vertex group multiple spots at once?

I can't use name sort or bone hierarchy sort because that's not how the groups should be ordered. The "copy group" function also sticks new groups on the end rather than after the selected group. The intuitive "click and drag" doesn't exist. I'm not seeing anything relevant in any expected locations.

$\endgroup$
1
$\begingroup$

Quick vg move addon.

enter image description here Debug run showing setter output to console. Move "Group" from top to bottom to top. Add new group "Group.040" and move to top

Here is a script solution to set the destination index of the active vg. To run copy, paste into text editor, run script and the slider will appear below the vg listbox.

Can install as addon.

bl_info = {
    "name": "Ouick Move Vertex Group",
    "author": "batFINGER",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "Properties > Mesh > Vertex Groups",
    "description": "Quickly move vertex groups",
    "warning": "",
    "wiki_url": "",
    "category": "Object",
}

import bpy
from bpy.props import IntProperty


def vgmove(delta):
    direction = 'UP' if delta > 0 else 'DOWN'
    for i in range(abs(delta)):
        bpy.ops.object.vertex_group_move(direction=direction)


def get_move_to(self):
    return self.vertex_groups.active_index


def set_move_to(self, value):
    delta = (self.vertex_groups.active_index - 
            min(value, len(self.vertex_groups) - 1))
    vgmove(delta)


bpy.types.Object.move_to_vg = IntProperty(
    name="Move to",
    get=get_move_to,
    set=set_move_to,
    min=0,
)


def draw_vg_move(self, context):
    layout = self.layout
    ob = context.object
    if ob and len(ob.vertex_groups):
        row = layout.row()
        row.prop(ob, "move_to_vg")


def register():
    bpy.types.DATA_PT_vertex_groups.append(draw_vg_move)


def unregister():
    bpy.types.DATA_PT_vertex_groups.remove(draw_vg_move)


if __name__ == "__main__":
    register()
$\endgroup$
  • $\begingroup$ Should've specified I was in 2.79b, but it works. Thanks. $\endgroup$ – Sir Teatei Moonlight Apr 19 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.