Forum: Poser 11 / Poser Pro 11 OFFICIAL Technical


Subject: Swapping left and right for an entire animation

evanhem opened this issue on Oct 08, 2020 ยท 4 posts


adp001 posted Thu, 08 October 2020 at 6:59 PM

This litle script may help:

import sys

if sys.version_info.major > 2:
    basestring = str
else:
    range = xrange

SCENE = poser.Scene()

SWAP_FUNCS = ["SwapTop",  # 0
              "SwapBottom",  # 1
              "SymmetryLeftToRight",  # 2
              "SymmetryRightToLeft",  # 3
              "SymmetryBotLeftToRight",  # 4
              "SymmetryBotRightToLeft",  # 5
              "SymmetryTopLeftToRight",  # 6
              "SymmetryTopRightToLeft",  # 7
              ]


def do_swap(actor=None, swap_function="SwapTop", keysfromscene=0, startframe=1):
    """
    :param actor:
    :param swap_function: String, name of the function to use.
    :param keysfromscene: Use framekeys from global scene or local actor. 1 == scene, 0 == actor.
    :param startframe: Frame nr to start (1 to n)
    """
    if actor is None:
        actor = SCENE.CurrentActor()
    figure = actor.ItsFigure()

    if isinstance(swap_function, int):
        swap_function = SWAP_FUNCS[swap_function]
    if isinstance(swap_function, basestring):
        swap = getattr(figure, swap_function, None)
        if swap:
            SCENE.SelectActor(actor)
            nextframe = SCENE.NextKeyFrameAll if keysfromscene == 1 else SCENE.NextKeyFrame

            framenr = startframe - 1
            while framenr is not None:
                SCENE.SetFrame(framenr)
                swap(0)
                framenr = nextframe()

            SCENE.DrawAll()


if __name__ == "__main__":
    idx = poser.DialogSimple.AskMenu("Select", "Swap method to use:", SWAP_FUNCS)
    if idx is not None:
        do_swap(swap_function=idx)

Simplest use: Select actor/figure you want to work with.

Start the script. It will ask for a methode you want to use to swap. For what you decribed, you may want to use "SwapTop". The script selects all keyframes inside the selected actor and performs a swap.