0
$\begingroup$

i have to delete some vertex groups. not the content but only the groups- need the later part of the script:

import bpy
context = bpy.context

import bpy


name_list = [
    # old name - new name
['Camo','Camo'],
['Corr','Corr'],
['Eyes','Eyes'],
['Head','head'],
['head_injury','head_injury'],
['Jaw_LM','Jaw_LM'],
['Jaw_RM','Jaw_RM'],
['Lip_LC','Lip_LC'],
['Lip_LwLF','Lip_LwLF'],
['Lip_LwRF','Lip_LwRF'],
['Lip_RC','Lip_RC'],
['Nose_L','Nose_L'],
['Nose_R','Nose_R'],
['Zig_LT','Zig_LT'],
['Zig_RT','Zig_RT'],
]

ob = context.object

for n in name_list:
    if n[0] in ob:
        ob.vertex_groups.remove(ob.pop())
$\endgroup$

1 Answer 1

0
$\begingroup$

I think this is what you're asking for, it deletes all the groups whose name appears in the first column of your list. I'm not sure why you decided to go with two columns.

import bpy
C = bpy.context

import bpy


name_list = [
    # old name - new name
['Camo','Camo'],
['Corr','Corr'],
['Eyes','Eyes'],
['Head','head'],
['head_injury','head_injury'],
['Jaw_LM','Jaw_LM'],
['Jaw_RM','Jaw_RM'],
['Lip_LC','Lip_LC'],
['Lip_LwLF','Lip_LwLF'],
['Lip_LwRF','Lip_LwRF'],
['Lip_RC','Lip_RC'],
['Nose_L','Nose_L'],
['Nose_R','Nose_R'],
['Zig_LT','Zig_LT'],
['Zig_RT','Zig_RT'],
]

ob =  C.active_object

for n in name_list:
    if n[0] in ob.vertex_groups:
        grp=ob.vertex_groups[n[0]]
        print(grp.name)
        ob.vertex_groups.remove(grp)
$\endgroup$

You must log in to answer this question.

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