Page MenuHome

Driver/Keyframes on object visibility do not update viewport
Closed, ResolvedPublicBUG

Description

Blender 2.8 Windows 64 bits version 30/08/2018 20:49

If one objet visibility option is changed using a driver, the visibility only changes after save and reload.

To reproduce:

The attached file has 2 objects, a Cube and a Suzanne monkey. There is a driver attached to suzanne to hide/show and the driver is handled using a custom prop of Cube. I know this is not a common use, but I tried to make a file as simple as possible to reproduce the bug.

  1. Open attached file
  2. Select the cube and in properties change "hide" property value to 1.
  3. Look at the outliner and verify hide property change in Suzanne.
  4. In viewport the Suzanne object still remain visible.
  5. Save and reload, the property now works.

I have tested the same driver hidden a collection and the problem is the same. Tested also in 2.79b and the drive hide/show suzanne without problems.

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

@Sergey Sharybin (sergey): just letting you know this gets reported quite often...

Really hoping this is fixed soon. It feels like a basic feature for all animators.

Still don't work with today build (downloaded from blender.org / beta section / windows 64).

If this can be useful ; I added the file I use to test this feature (see attached blend file).

The cube should desapear if you move up the constrained cone.
With the current build, I noticed that the outliner updates correctly when you hoover it with mouse cursor (icons updates, sometimes with a bit lag, as long as you hoover the outliner with the mouse cursor) but the 3D view won't update. You will have to disable/enable the cube object selection in the outliner, then the 3D view will update.

Also, if you play too much with the 3D view visibility of the cube inside the outliner (the eye icon) it will krashes blender, and/or have unpredictable behaviours.

Hope this would help a bit...

i've just found this problem - keyframing renderability for a Plane object and a Point Lamp are not working in an animation file that worked at 2.79

To get around the issues with keyframing visibility in 2.80, I used a script instead.

import bpy

# create a list of frames:
frames = []
for i in range(26):
    frames.append([str(i)])


# define which objects are visible on each frame:
frames[1] = ['object1']
frames[2] = ['object2', 'object3']
frames[3] = ['object1', 'object4', 'object2']

# define the function that runs before we advance to the next frame:
def run_script(scene):
    
    objects = bpy.data.collections['subject'].objects

    current_frame = bpy.context.scene.frame_current

    for object in objects:
        if object.name in frames[current_frame]:
            object.hide_viewport = False
            object.hide_render = False
        else:
            object.hide_viewport = True
            object.hide_render = True

bpy.app.handlers.frame_change_pre.append(run_script)

There's probably a more pythonic way to write this but it works!

I allready had this problem in a few projects.
Thank you @Fletcher Graham (fletchgraham) for your suggestion on forcing blender to update through python.

Here is my temporary fix.
After running the script the keyframes should behave as usual.

import bpy

render_only = False

def hide_on_render(scene):
    current_frame = bpy.context.scene.frame_current
    
    for object in bpy.data.objects:
        fcurve = object.animation_data.action.fcurves.find('hide_render')
        
        if fcurve:
            hide = fcurve.evaluate(current_frame) > 0

            object.hide_viewport = hide
            object.hide_render = hide
        

if render_only:
    bpy.app.handlers.render_pre.append(hide_on_render)
else:
    bpy.app.handlers.frame_change_pre.append(hide_on_render)

I've the same problem.
I believe that being able to control visibility on viewport is very important.

Using scripts can be a patch, but I doubt it is the best solution.
It was better than it was before.

I've just discovered this problem. I don't really understand the script workaround, but I know it's something with the internal code not updating. Because if I move a keyframe of Disable Render channel from the object, it will be updated, but then stays like the last render until I move any keyframe of Disable Render channel again.

Also I don't know if I should write here or create another task, but I can't even insert keyframe on viewport visibility, while I can insert one for render visibility. It will show an error as shown in the screenshot:


If some people with earlier build can insert keyframe on viewport visibility, even if they don't update correctly, is this one more regression from earlier build or intended to prevent crash? I've tried this on few builds that I still have, with the earliest build on 552b2287db86 (01/02/2019) and the latest build blender-2.80-d3870471edd7-win64 (12/02/2019).

Sergey Sharybin (sergey) changed the task status from Unknown Status to Resolved.Feb 28 2019, 4:51 PM

Committed quite some fixes in various related ares and this report is supposed to be fixed now! The minimal revision required is rB846d265a06e.

Thanks for the report, closing.

Sylvain (Micool) added a comment.EditedMar 1 2019, 2:55 PM

On blender-2.80-e795dd4a20a1-win64

This fix created a new issue on the rendering an hidden object

:

Please try to render this example when the cube is disabled -> blender crashes.

@Sylvain (Micool), please create a new bug report about that.

@Sergey Sharybin (sergey) : this will make me the happiest man :)
I'll test it in the next build.
Thanks a lot.

Bronson (DBAGibbz) added a comment.EditedMar 2 2019, 6:13 AM

Hi Guys,

Im trying the new build, and still cannot animate the "Hide collection in viewport" (the eye icon). Is there some hidden way to animate this value now that its fixed? The tooltip doesnt give me any clues....

Edit:
Looks like on collections these values are still not animatable on either of them....

collection = bpy.data.collections.new("Frame_" + str(fi))
collection.hide_render = False
collection.hide_viewport = False
collection.keyframe_insert( data_path="hide_viewport",
index=-1,
frame=current_frame)
collection.keyframe_insert( data_path="hide_render",
index=-1,
frame=current_frame)

TypeError: bpy_struct.keyframe_insert() property "hide_viewport" not animatable

Currently only objects visibility is animated.

Allowing animation of collection animation is possible, but is more tricky to implement without loosing ability to keep memory footprint in control.

For now you can instance the collection and control visibility of the instancer.

Hello, I am facing the same problem.
Can someone give an example or a step by step guide of how to key visibility on instanced collection or object? (with the latest build of blender 2.80)

It would be appreciated a lot!
Thanks,

Likewise just tried object visibility keyframing in latest build as of today (Mac) and still no option to keyframe or add drivers to object viewport visibility (eye icon in outliner). This is quite a crucial feature for me to start migrating my main project to 2.80

Can confirm, this persists on 2.82.6 and 2.83 alpha.
I have attached a sample file and a demo video.


The file only has a cube with a single Custom Property called "Visibility" on it. Range is 0 to 1.
This drives both Viewport and Render Visibility.

If you activate and deactivate it by dragging, it goes amiss a little less often, but with the arrows, it glitches out irregularly, roughly about 1 in 5 times.

I can confirm this. I have the same problem. I have an armature with a mesh parented to it and a properties bone. I tried to drive the visibility of the mesh both in viewport and render and switch between hiding and revealing them using that bone. But I can't hide/reveal them both at same time. Some times they do, sometimes they interchange. In other words, the driver of hiding the mesh in viewport alone works fine with the bone, but if you also drive the rendering, then it bugs and doesn't allow you to hide/reveal them both at the same time, only one at a time. Saving and reloading the file doesn't work for me.

Visibility drivers are not only extremely useful but most of the time necessary, they speed things up and make life much easier, so we can't have them bugging. I strongly suggest you fix this issue as soon as possible. Thank you.

ML (spawn_x) added a subscriber: ML (spawn_x).