Exemplo n.º 1
0
def smooth_selected_keyframes():
    """
    Smooth the selected keyframes in the Graph Editor.

    Usage:

    1. Select keyframes in Graph Editor.
    2. Run tool
    3. Keyframe values will be smoothed.

    """
    key_attrs = maya.cmds.keyframe(query=True, name=True) or []
    if len(key_attrs) == 0:
        msg = (
            'Please select keyframes '
            '(in the Graph Editor) to smooth.'
        )
        LOG.warning(msg)
        return

    smooth_type = configmaya.get_scene_option(
        const.CONFIG_MODE_KEY,
        default=const.DEFAULT_MODE)
    width = configmaya.get_scene_option(
        const.CONFIG_WIDTH_KEY,
        default=const.DEFAULT_WIDTH)

    blend_smooth_type = utils_const.SMOOTH_TYPE_GAUSSIAN
    blend_width = configmaya.get_scene_option(
        const.CONFIG_BLEND_WIDTH_KEY,
        default=const.DEFAULT_BLEND_WIDTH)

    undo_id = 'smoothkeyframes: '
    undo_id += str(datetime.datetime.isoformat(datetime.datetime.now()))
    undo_id += ' '
    undo_id += str(uuid.uuid4())
    with undo_utils.undo_chunk_context(undo_id):
        for key_attr in key_attrs:
            selected_keyframes = maya.cmds.keyframe(
                key_attr,
                query=True,
                selected=True
            ) or []
            if len(selected_keyframes) == 0:
                msg = (
                    'Please select keyframes '
                    '(in the Graph Editor) to smooth.'
                )
                LOG.warning(msg)
                continue

            lib.smooth_animcurve(
                key_attr,
                selected_keyframes,
                smooth_type,
                width,
                blend_smooth_type,
                blend_width)
    return
Exemplo n.º 2
0
def smooth_selected_keyframes():
    """
    Smooth the selected keyframes in the Graph Editor.

    Usage::

    1) Select keyframes in Graph Editor.

    2) Run tool

    3) Keyframe values will be smoothed.

    """
    key_attrs = maya.cmds.keyframe(query=True, name=True) or []
    if len(key_attrs) == 0:
        msg = ('Please select keyframes ' '(in the Graph Editor) to smooth.')
        LOG.warning(msg)
        return

    for key_attr in key_attrs:
        selected_keyframes = maya.cmds.keyframe(
            key_attr, query=True, selected=True) or []
        if len(selected_keyframes) == 0:
            msg = ('Please select keyframes '
                   '(in the Graph Editor) to smooth.')
            LOG.warning(msg)
            continue

        smooth_type = configmaya.get_scene_option(const.CONFIG_MODE_KEY,
                                                  default=const.DEFAULT_MODE)
        width = configmaya.get_scene_option(const.CONFIG_WIDTH_KEY,
                                            default=const.DEFAULT_WIDTH)

        blend_smooth_type = utils_const.SMOOTH_TYPE_GAUSSIAN
        blend_width = configmaya.get_scene_option(
            const.CONFIG_BLEND_WIDTH_KEY, default=const.DEFAULT_BLEND_WIDTH)

        lib.smooth_animcurve(key_attr, selected_keyframes, smooth_type, width,
                             blend_smooth_type, blend_width)
    return
Exemplo n.º 3
0
def main():
    """
    Smooth the selected keyframes in the Graph Editor.

    Usage::

    1) Select keyframes in Graph Editor.

    2) Run tool

    3) Keyframe values will be smoothed.

    """
    key_attrs = maya.cmds.keyframe(query=True, name=True) or []
    if len(key_attrs) == 0:
        msg = ('Please select keyframes ' '(in the Graph Editor) to smooth.')
        LOG.warning(msg)
        return

    for key_attr in key_attrs:
        selected_keyframes = maya.cmds.keyframe(key_attr,
                                                query=True,
                                                selected=True)
        if len(selected_keyframes) == 0:
            msg = ('Please select keyframes '
                   '(in the Graph Editor) to smooth.')
            LOG.warning(msg)
            continue

        smooth_type = utils_const.SMOOTH_TYPE_FOURIER
        width = 2
        blend_smooth_type = utils_const.SMOOTH_TYPE_GAUSSIAN
        blend_width = 2
        lib.smooth_animcurve(key_attr, selected_keyframes, smooth_type, width,
                             blend_smooth_type, blend_width)
    return