3
$\begingroup$

For example:

bpy.data.textures["mouth shapes"].image_user.frame_offset = bpy.data.objects["rigMeenuTeen"].pose.bones["eyes"].location

Can this kind of expression be a driver?

$\endgroup$
0

1 Answer 1

4
$\begingroup$

If the property doesn't allow for drivers, it cannot be driven with a driver.

It can be driven through app.handlers though:

import bpy

def my_handler(scene):
    # this code will be run on every frame change
    loc = bpy.data.objects["rigMeenuTeen"].pose.bones["eyes"].location
    bpy.data.textures["mouth shapes"].image_user.frame_offset = int(loc.x)

bpy.app.handlers.frame_change_pre.append(my_handler)
$\endgroup$
4
  • $\begingroup$ thanks. "frame_change_post" is not updating in 3D viewport. But "frame_change_pre" is updating and working fine. Non-scripted drivers updating update even interactively (i mean when i move driver around with mouse it affects driven) is that possible in scripted way? $\endgroup$
    – ashwin
    May 6, 2015 at 3:46
  • $\begingroup$ @ashwin Fixed the answer to '_pre' handler. Can you specify what you mean with the last question? Classic drivers cannot update (call) events, but PyDrivers could. I am not sure if that is what you were asking.. $\endgroup$ May 6, 2015 at 6:07
  • $\begingroup$ i mean when i add driver through right click and specify driver details in driver window. Then that driver affects the driven even when its moved with mouse. But this scripted driver only affects when we play the animation. Or is ther "on_mouse_move" handler available like "frame_change_pre" ? $\endgroup$
    – ashwin
    May 6, 2015 at 6:22
  • $\begingroup$ @ashwin no, there isn't 'on_mouse_move' but there is 'scene_update' which basically runs all the time. Executing a function there might slow down blender a lot so if you really must the best is to setup a monitor for that property like this: blender.stackexchange.com/questions/19668/…. Instead of a name you can watch a bone's position and update the frame_offset accordingly $\endgroup$ May 6, 2015 at 6:48

You must log in to answer this question.

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