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


evanhem posted Thu, 08 October 2020 at 3:21 PM

Hello, I have a sequence of movements that are done with the right arm. The animation is 1144 frames. I basically key the right arm joints at various frames and interpolate for the rest: image.png

For the whole motion, the left arm and everything else is fixed.

I would like to generate a new motion that is the exact mirror of this one.

I noticed that if I use Pose Symmetry -> Swap right and left, that it is only valid for one frame at a time. I thought that maybe swapping every key frame would work, but it does not fully mirror the motion.

Is there a way to do this automatically without too much labor?

Thank you.


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.




evanhem posted Fri, 09 October 2020 at 11:16 AM

Thanks! I think Swap Top worked pretty well. Only thing I had to manually do was then delete the old key frames for the opposing side and then change the interpolation type to linear, to preserve what I had before, since default is spline.

The code is simple enough to where it can continue to help me understand Python and the Poser methods.


caisson posted Mon, 12 October 2020 at 1:28 PM

I think that Pose Symmetry - Custom allows you to specify a frame range ... IIRC.

----------------------------------------

Not approved by Scarfolk Council. For more information please reread. Or visit my local shop.