5
$\begingroup$

I am working with a blender3d animation where I need some objects appear/hide at specific frames. I made all the work using the eye icon (visibility view-port) instead of camera icon (render-visibility) before discovering that they are not the same :(

Aside from animating everything again and hitting my head on the wall for not reading the whole manual, is there some python script or something to move the existing animation keyframes from one channel to the other?

$\endgroup$
4
$\begingroup$

you can use this script to :

  • clean the render visibility channels
  • create new render visibility channel from the viewport visibility channel

Note : this is for all object in the current scene


import bpy


# clean all render view channels            
for action in bpy.data.actions :
    for fcurve in action.fcurves :
        if fcurve.data_path == 'hide_render':
              action.fcurves.remove(fcurve)

#create new render view channel and fill it from the viewport view channel
for action in bpy.data.actions :
    for fcurve in action.fcurves :
        if fcurve.data_path == 'hide':
            render_fcurve = action.fcurves.new('hide_render')
            for p in fcurve.keyframe_points :
                render_fcurve.keyframe_points.insert(p.co[0], p.co[1])
                #set the interpolation from BEZIER to CONSTANT
                render_fcurve.keyframe_points[-1].interpolation = 'CONSTANT'
            break
$\endgroup$
  • $\begingroup$ thanks Chebhou, your script does exactly what I needed. The only issue I found was that when you animate by clicking the camera and eye icons, the interpolation mode is of type CONSTANT, while the one produced by your script is of type BEZIER. So I added a second pass to your script to fix that (I couldn't find a way to do it in the same pass) $\endgroup$ – cesarpachon Apr 5 '15 at 19:42
  • $\begingroup$ @cesarpachon feel free to edit my answer and add it $\endgroup$ – Chebhou Apr 5 '15 at 19:45

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.