How to get object's driver value at given frame

Let’s assume I have object “X” with driver assign to it. Is it possible to get driver value at given frame in some other script?

Thanks

ob = bpy.data.objects[“X”]

drv = ob.animation_data.drivers[0] # e.g. the first one
drv.evaluate(frame_num)

Thanks a lot.

But how to do the same for driver which was assigned to bone instead of object? I guess I should use AnimData object which is bound to particular bone, but I couldn’t find it. I was considering following paths:

bpy.data.objects[“arm_name”].pose.bones[“bone_name”] - no anim data here
bpy.data.objects[“arm_name”].data.bones[“bone_name”] - neither here

And this is strange: I can see following property

bpy.data.objects[“arm_name”].data.animation_data

but it seems to be empty. If I execute “pprint(dir(bpy.data.objects[“arm_name”].data.animation_data))” then I get following output:

[‘bool’,
class’,
delattr’,
dir’,
doc’,
eq’,
format’,
ge’,
getattribute’,
gt’,
hash’,
init’,
le’,
lt’,
ne’,
new’,
reduce’,
reduce_ex’,
repr’,
setattr’,
sizeof’,
str’,
subclasshook’]

Unfortunately I have no other idea where to look for it.

well it’s apparently in Object.animation_data too?!

>>> C.object.animation_data.drivers[0].data_path
‘pose.bones[“Bone”].rotation_quaternion’

It works wonderfully - thanks a lot for your help.