Exemple #1
0
 def unbind(cls, obj):
     from mmd_tools_local.bpyutils import ObjectOp
     if obj.data.shape_keys:
         if cls.SHAPEKEY_NAME in obj.data.shape_keys.key_blocks:
             ObjectOp(obj).shape_key_remove(obj.data.shape_keys.key_blocks[cls.SHAPEKEY_NAME])
     for mod in obj.modifiers:
         if mod.type == 'ARMATURE' and mod.vertex_group == cls.MASK_NAME:
             mod.vertex_group = ''
             mod.invert_vertex_group = False
             break
     if cls.MASK_NAME in obj.vertex_groups:
         obj.vertex_groups.remove(obj.vertex_groups[cls.MASK_NAME])
     cls.clear_cache(obj)
Exemple #2
0
    def __cleanup(self, names_in_use=None):
        names_in_use = names_in_use or {}
        rig = self.__rig
        for mesh in rig.meshes():
            for kb in getattr(mesh.data.shape_keys, 'key_blocks', ()):
                if kb.name.startswith('mmd_bind') and kb.name not in names_in_use:
                    kb.driver_remove('value')
                    kb.relative_key.mute = False
                    ObjectOp(mesh).shape_key_remove(kb)
            for m in mesh.modifiers: # uv morph
                if m.name.startswith('mmd_bind') and m.name not in names_in_use:
                    mesh.modifiers.remove(m)

        attributes = set(TransformConstraintOp.min_max_attributes('LOCATION', 'to'))
        attributes |= set(TransformConstraintOp.min_max_attributes('ROTATION', 'to'))
        for b in rig.armature().pose.bones:
            for c in b.constraints:
                if c.name.startswith('mmd_bind') and c.name[:-4] not in names_in_use:
                    for attr in attributes:
                        c.driver_remove(attr)
                    b.constraints.remove(c)
Exemple #3
0
 def remove_shape_key(obj, key_name):
     key_blocks = getattr(obj.data.shape_keys, 'key_blocks', None)
     if key_blocks and key_name in key_blocks:
         ObjectOp(obj).shape_key_remove(key_blocks[key_name])