10
$\begingroup$

If there is an object which has a property that which varies with each frame, would it be possible to to build a script that can access that property before each frame is rendered and thus change another property?

$\endgroup$
4
  • $\begingroup$ It does seem to answer the question of running the script before rendering. But would it be done before each frame is rendered? Also I'm new to scripting. $\endgroup$ Commented Mar 21, 2015 at 21:04
  • $\begingroup$ You could try using calling this function: bpy.app.handlers.frame_change_post with a function as a parameter. Check the API here: blender.org/api/blender_python_api_2_60_6/bpy.app.handlers.html $\endgroup$ Commented Mar 21, 2015 at 21:11
  • 1
    $\begingroup$ Could you provide your current script, so I can modify it to do what you want? $\endgroup$ Commented Mar 21, 2015 at 21:15
  • $\begingroup$ Sorry but I have no script. I'm thinking about creating an addon and I wanted some knowledge of how to do so. Thanks for the offer, I'd really like to collaborate with someone sometime in the future. $\endgroup$ Commented Mar 21, 2015 at 21:49

1 Answer 1

15
$\begingroup$

One way is by using drivers. Drivers allow you to calculate a value to use, this may be from other values in the same object, or from other objects. This answer provides examples. Also consider that drivers may be disabled by the user.

Another way is to setup a handler function. You could choose between using frame_change_post or a render_pre. You simply define your function and then append it to the handler list, then remove it when it is no longer needed.

def my_handler(scene):
    val = scene.objects['Cube'].location.x
    scene.objects['Sphere'].location.y = val + 1.6

def register():
    bpy.app.handlers.frame_change_post.append(my_handler)

def unregister():
    bpy.app.handlers.frame_change_post.remove(my_handler)
$\endgroup$

You must log in to answer this question.

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