Combine 2 fonctions

Hi all,

I did 2 custom keying sets to keyframe viewport and render visibilty. As I have no knowledge of python, I did this by analogy with existing code and now, I would like to keyframe viewport and render visibility in one time. Even by analogy with existing keying sets, I’m stucked.

# Hide Render
class BUILTIN_KSI_Hide_Render(KeyingSetInfo):
    bl_label = "Hide_Render"

    # poll - test for whether Keying Set can be used at all
    def poll(ksi, context):
        return context.active_object or context.selected_objects

    # iterator - go over all relevant data, calling generate()
    def iterator(ksi, context, ks):
        for ob in context.selected_objects:
            ksi.generate(context, ks, ob)

    # generator - populate Keying Set with property paths to use
    def generate(ksi, context, ks, data):
        id_block = data.id_data

        ks.paths.add(id_block, "hide_render")

# Hide Viewport
class BUILTIN_KSI_Hide_Viewport(KeyingSetInfo):
    bl_label = "Hide_Viewport"

    # poll - test for whether Keying Set can be used at all
    def poll(ksi, context):
return context.active_object or context.selected_objects

    # iterator - go over all relevant data, calling generate()
    def iterator(ksi, context, ks):
        for ob in context.selected_objects:
            ksi.generate(context, ks, ob)

    # generator - populate Keying Set with property paths to use
    def generate(ksi, context, ks, data):
        id_block = data.id_data

        ks.paths.add(id_block, "hide")

To be clear : if it’s easy to do by someone who know how it works (and so take a little amount of time), I’ll take the code but as I ask this as a service and not really for a help to code myself as I can’t (I use python very rarely so I don’t really want to go deeper by learning it), I understand if nobody cares :).

Ok, doing this work (thanks to edddy from an other forum) :

# Hide Render
class BUILTIN_KSI_Hide_Render(KeyingSetInfo):
    bl_label = "Hide_Render"

    # poll - test for whether Keying Set can be used at all
    def poll(ksi, context):
        return context.active_object or context.selected_objects

    # iterator - go over all relevant data, calling generate()
    def iterator(ksi, context, ks):
        for ob in context.selected_objects:
            ksi.generate(context, ks, ob)

    # generator - populate Keying Set with property paths to use
    def generate(ksi, context, ks, data):
        id_block = data.id_data

        ks.paths.add(id_block, "hide_render")
        ks.paths.add(id_block, "hide")