0
$\begingroup$

I hope to check whether each pose bone transform values are driven or not by bpy..

At current I check it by bone name which rig vendor set (like sholder_drv), it work for the rig but I hope to know more flexible way to check the bone property have driver or not.

Is there good way only get pose bones which have no driven property? (about this case, I only need to check pose transform value is driven or not)

/////////////////////////////////////

At current I could get driver path of the armatture fcurve

'''
def get_driver_list(ob, li):
    drvs = ob.animation_data.drivers
    if drvs is not None:
        for drv in drvs:
            drv_path = drv.data_path
            print(drv_path)
            li.append(drv_path)
    return False
'''

Then Current problem is, data_path type = string so I could get path, but could not find easy way to get bone name, which include in the driver data_path. (need strict check,,)

'pose.bones["lSmallToe4Drv"].rotation_euler'

Is there good way to access bone.property by data_path.to get the bone.name correctly?

$\endgroup$
2
  • $\begingroup$ Does this answer your question? Check if a property is animated or has a driver Especially the comment on the first answer should help you $\endgroup$
    – Gorgious
    Commented Aug 31, 2020 at 9:32
  • $\begingroup$ Hi thanks Gorgious yes your mentioned topic is really help me to access driver.But I still have difficulity to check the bone have driver or not. the discribed is OK to check each property directly. But I need to check all property of bone pose related. So I hope to get answer which more directly return "False" or "True" about bone. $\endgroup$
    – tokikake
    Commented Aug 31, 2020 at 10:49

1 Answer 1

1
$\begingroup$

I think there should be better way, but I feel it worked for me.

import bpy
def get_driver_list(ob):
    drvs = ob.animation_data.drivers
    li = []
    if drvs is not None:
        for drv in drvs:
            drv_path = drv.data_path
            li.append(drv_path)
    return li

def get_bone_driven(ob, bn):
    flag = False
    li = get_driver_list(ob)
    bn_path = ob.pose.bones[bn].path_from_id()
    for path in li:
        if bn_path in path:
            flag = True
            print(bn_path, "in" , path)
            break

    return(flag)

ob = bpy.context.object

for pb in ob.pose.bones:
    if get_bone_driven(ob, pb.name):
        print(pb.name)
$\endgroup$

You must log in to answer this question.

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