I wrote this little script to toggle the visibility of the shadows of all objects.
It works quite well, but at the end of the script, I'd like to update the viewport. I tried the "hack" with the redraw_timer, but actually I don't want to use it, because it's not recommended and mainly because it doesn't work with the blender version 2.78c. ;-)
import bpy for ob in bpy.data.objects: try: ob.cycles_visibility.shadow ^= 1 except: print ("No shadows: ", ob.name) # Did not work: # bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) bpy.context.window.screen = bpy.data.screens["Scripting"] bpy.context.window.screen = bpy.data.screens["Default"]
So I just switched to another screen layout and back to default.
That works. However, I guess there are more elegant ways to do this.
Thanks brockmann, thanks @all Here's the updated and tested version:
import bpy for ob in bpy.data.objects: try: ob.cycles_visibility.shadow ^= 1 except: print ("No shadows: ", ob.name) bpy.context.scene.update_tag()