3
$\begingroup$

I have following problem.

With the minecraft rig works everything fine (thomas rig) but when I open the console there are displayed invalid drivers of already deleted objects. How can I delete them? Even if select everything in the outliner and then go to the driver editor these aren't displayed. Therefore I can't delete them. So how can I delete them? I am really struggling with that.

enter image description here

$\endgroup$
4
$\begingroup$

Remove, since removed shape-key drivers.

From pic in question appears they are shape key drivers, which remain if a keyblock is removed, renamed (To reproduce, add a shapekey "Key 1", give it a driver, delete the shapekey. Then add a new key, and since its name is "Key 1" bingo it has a driver... )

Code to remove invalid path shape key drivers.

import bpy

for sk in bpy.data.shape_keys:
    if not sk.animation_data:
        continue
    bung_drivers = []
    # find bung drivers
    for d in sk.animation_data.drivers:
        try:
            sk.path_resolve(d.data_path)
        except ValueError:
            bung_drivers.append(d)
    # remove bung drivers
    while bung_drivers:
        sk.animation_data.drivers.remove(
                bung_drivers.pop()
                )

Generic, for all ID types

Loop over all ID types in the data of the blend and remove any driver whose path does not resolve.

import bpy
from bpy import data
from bpy.types import bpy_prop_collection

colls = [
    p for p in dir(data)
    if isinstance(getattr(data, p), bpy_prop_collection)
    ]

for p in colls:
    for ob in getattr(data, p, []):
        ad = getattr(ob, "animation_data", None)
        if not ad:
            continue
        bung_drivers = []
        # find bung drivers
        for d in ad.drivers:
            try:
                ob.path_resolve(d.data_path)
            except ValueError:
                bung_drivers.append(d)
        # remove bung drivers
        while bung_drivers:
            ad.drivers.remove(
                    bung_drivers.pop()
                    )
$\endgroup$
4
  • $\begingroup$ Hello batFinger, thanks for the help! I now have run the code and most of the errors are gone now. But there are still some errors about bone constraints like this: WARN (bke.anim_sys): C:\b\buildbot-worker-windows\windows_291\blender.git\source\blender\blenkernel\intern\anim_sys.c:2926 BKE_animsys_eval_driver: invalid driver - pose.bones["L.Leg_knee.009"].constraints["Copy Rotation"].mute[0] and how would i remove these then? thanks in advance :D $\endgroup$
    – BlueEvil
    Feb 20 at 16:39
  • 1
    $\begingroup$ Back up first. Try replacing bpy.data.shape_keys with bpy.data.objects. (In theory "should" be able to roll this over all bpy.data collections) $\endgroup$
    – batFINGER
    Feb 20 at 17:05
  • 1
    $\begingroup$ This is awesome ! The error messages also pop up when you delete a modifier with drivers without deleting its drivers first and it's a pain in the *** to look for when you have a lot of objects $\endgroup$
    – Gorgious
    Feb 21 at 8:49
  • $\begingroup$ I have tried it and it works perfectly for me! Every error is now gone. Thanks for you help. $\endgroup$
    – BlueEvil
    Feb 21 at 9:32

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.