How to Animate all of the Toggle Visible and render ?

Animation tools, character animation, non linear animation

Moderators: jesterKing, stiv

Post Reply
tititi
Posts: 0
Joined: Tue Dec 04, 2012 10:55 am
Location: Thailand

How to Animate all of the Toggle Visible and render ?

Post by tititi » Tue Dec 04, 2012 11:07 am

How to Animate all of the Toggle Visible and render in one time ?


Image

CoDEmanX
Posts: 0
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Post by CoDEmanX » Tue Dec 04, 2012 10:52 pm

Here's a really rough solution (you should turn it into an addon):

Code: Select all

import bpy

class OUTLINER_OT_keyframe_objects_hidden(bpy.types.Operator):
    """Keyframe all objects to be hidden or shown (view and render)"""
    bl_idname = "outliner.keyframe_objects_hidden"
    bl_label = "Keyframe objects hidden/shown"
    bl_options = {'REGISTER', 'UNDO'}

    hide = bpy.props.BoolProperty(default=True, name="Hide objects", description="Whether to keyframe all objects as hidden or shown")
    
    def execute(self, context):
        for ob in bpy.data.objects:
            ob.hide = self.hide
            ob.hide_render = self.hide
            ob.keyframe_insert("hide")
            ob.keyframe_insert("hide_render")
        return {'FINISHED'}

def keyframe_objects_hidden(self, context):
    layout = self.layout
    layout.separator()
    layout.operator("outliner.keyframe_objects_hidden", text="Keyframe objects hidden")
    layout.operator("outliner.keyframe_objects_hidden", text="Keyframe objects shown").hide = False
    

def register():
    bpy.utils.register_class(OUTLINER_OT_keyframe_objects_hidden)
    bpy.types.OUTLINER_MT_view.append(keyframe_objects_hidden)

def unregister():
    bpy.utils.unregister_class(OUTLINER_OT_keyframe_objects_hidden)
    bpy.types.OUTLINER_MT_view.remove(keyframe_objects_hidden)

if __name__ == "__main__":
    register()

    # test call
    #bpy.ops.object.simple_operator()
it adds two new entries to the outliner view menu to keyframe all objects hidden or shown.
I'm sitting, waiting, wishing, building Blender in superstition...

tititi
Posts: 0
Joined: Tue Dec 04, 2012 10:55 am
Location: Thailand

.

Post by tititi » Thu Dec 06, 2012 3:58 am

Hello thank you very much for your help
I already saw the new entries in the outliner view + menu keyframe objects hidden or shown, but when I hit that command it nothing happen on visibility icon , how could I do ? :cry: thanks again.

CoDEmanX
Posts: 0
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Post by CoDEmanX » Thu Dec 06, 2012 2:18 pm

you are right, for some reason the operator doesn't use the default property value hide=True. Here's an addon version with this issue fixed:

Code: Select all

bl_info = {
    "name": "Keyframe objects hidden/shown",
    "description": "Keyframe all objects to be hidden or shown (view and render)",
    "author": "CoDEmanX",
    "version": (0, 2),
    "blender": (2, 64, 0),
    "location": "Outliner > View > Keyframe objects ...",
    "warning": "Roughly written operator, not well designed",
    "category": "Animation"}

import bpy 

class OUTLINER_OT_keyframe_objects_hidden(bpy.types.Operator): 
    """Keyframe all objects to be hidden or shown (view and render)""" 
    bl_idname = "outliner.keyframe_objects_hidden" 
    bl_label = "Keyframe objects hidden/shown" 
    bl_options = {'REGISTER', 'UNDO'} 

    hide = bpy.props.BoolProperty(default=True, name="Hide objects", description="Whether to keyframe all objects as hidden or shown")
    sel_only = bpy.props.BoolProperty(default=False, name="Selection only", description="Keyframe the current selection only instead of all objects in scene")
    
    def execute(self, context): 
        for ob in context.scene.objects:
            if self.sel_only and not ob.select:
                continue
            ob.hide = self.hide 
            ob.hide_render = self.hide 
            ob.keyframe_insert("hide") 
            ob.keyframe_insert("hide_render") 
        return {'FINISHED'} 

def keyframe_objects_hidden(self, context): 
    layout = self.layout 
    layout.separator() 
    layout.operator("outliner.keyframe_objects_hidden", text="Keyframe objects hidden").hide = True
    layout.operator("outliner.keyframe_objects_hidden", text="Keyframe objects shown").hide = False
    

def register(): 
    bpy.utils.register_class(OUTLINER_OT_keyframe_objects_hidden) 
    bpy.types.OUTLINER_MT_view.append(keyframe_objects_hidden) 

def unregister(): 
    bpy.utils.unregister_class(OUTLINER_OT_keyframe_objects_hidden) 
    bpy.types.OUTLINER_MT_view.remove(keyframe_objects_hidden) 

if __name__ == "__main__": 
    register() 

    # test call 
    #bpy.ops.object.simple_operator() 
I'm sitting, waiting, wishing, building Blender in superstition...

tititi
Posts: 0
Joined: Tue Dec 04, 2012 10:55 am
Location: Thailand

.

Post by tititi » Sun Dec 09, 2012 12:03 pm

Thank you for your help
If in case I have more question, I will consult you again. Hope you don't mind.

Post Reply