Adverti horiz upsell

Manip Hotkeys for Animation 1.0.0 for Maya (maya script)

Hotkeys for x, y, z channels for translate, rotation and scale.

License
Button download
179 Downloads

Compatibility

  • 2017, 2016

Operating Systems

  • Linux
  • Mac
  • Windows

History

Created:10/01/2016
Last Modified:10/02/2016
File Size: 56 KB
per page
1-3 of 3

Reviews Love it? Or maybe you want to share some creative ways you're putting this item to use.

  • boby Thompson

    boby Thompson said 11 months ago:

     

    maya 2022 fix

    '''
    rb_manipHotkeys.py

    Maya script

     

    Author:
    Ron Bublitz
    Copyright (c) 2016. All rights reserved.

    Revisions:
    Oct 2016 Initial version

    '''


    import maya.cmds as cmds

    kChanBox = 'mainChannelBox'
    kTransColor = [0.604, 0.357, 0.357]
    kRotColor = [0.357, 0.604, 0.357]
    kScaleColor = [0.357, 0.596, 0.604]
    kNormalColor = [0.333, 0.349, 0.353]

    kStandardColor = [.322, .522, .651]
    kPrevMode = None
    kManipContexts = ['moveSuperContext', 'RotateSuperContext', 'scaleSuperContext']

    kChannelBoxScriptJob = None


    def rb_selectChannelCommand(axis = 'x', planeMode = False):
    '''Enters the correct manip context based on the axis specified.
    '''

    global kPrevMode
    global kChanBox

    # get current Context
    curContext = cmds.currentCtx()
    if curContext not in kManipContexts:
    curContext = kPrevMode
    else:
    kPrevMode = curContext

    axisList = ['x', 'y', 'z']
    if planeMode:
    axisList.remove(axis)
    else:
    axisList = list(axis)

    selList = cmds.ls(selection = True)
    if curContext == kManipContexts[0]:
    attr = '.t'
    elif curContext == kManipContexts[1]:
    attr = '.r'
    else:
    attr = '.s'

    plugList = list()
    for axis in axisList:
    plugList = plugList + [x + attr + axis for x in selList]

    cmds.channelBox(kChanBox, e = True, select = plugList, useManips = 'standard')


    def rb_channelBoxSelectionChanged():
    '''Changes the channel box highlight colour based on the channel selections.
    '''

    #global kChannelBoxScriptJob
    #if kChannelBoxScriptJob is None:
    # kChannelBoxScriptJob = cmds.scriptJob(event = ['ChannelBoxLabelSelected', rb_channelBoxSelectionChanged ], permanent = True )

    global kChanBox
    cbSelection = cmds.channelBox(kChanBox, q = True, selectedMainAttributes = True)
    if cbSelection is None:
    return

    channelType = set()
    for axis in ['tx', 'ty', 'tz']:
    for i in cbSelection:
    if i == axis:
    channelType.add('t')
    for axis in ['rx', 'ry', 'rz']:
    for i in cbSelection:
    if i == axis:
    channelType.add('r')
    for axis in ['sx', 'sy', 'sz']:
    for i in cbSelection:
    if i == axis:
    channelType.add('s')

    # check if there's one that one manip type
    if len(channelType) != 1:
    channelType = ['m']

    if 't' in channelType:
    cmds.channelBox(kChanBox, e = True, hlc = kTransColor)
    elif 'r' in channelType:
    cmds.channelBox(kChanBox, e = True, hlc = kRotColor)
    elif 's' in channelType:
    cmds.channelBox(kChanBox, e = True, hlc = kScaleColor)
    else:
    cmds.channelBox(kChanBox, e = True, hlc = kNormalColor)


    #############################################
    # setup

    def rb_setupChannelBoxSelectionScriptJob():
    global kChannelBoxScriptJob
    kChannelBoxScriptJob = cmds.scriptJob(event = ['ChannelBoxLabelSelected', rb_channelBoxSelectionChanged ], permanent = True )


    def rb_setupHotkeys():
    '''Adds the channel hotkeys to the 'x', 'c' and 'v' keyboard keys.
    If there is not a current user hotkey set, it will create it.
    '''
    # check if using the default hotkey set
    if cmds.hotkeySet(q = True, current = True) == 'Maya_Default':
    if not cmds.hotkeySet('User', q = True, exists = True):
    cmds.hotkeySet('User', current = True)
    else:
    cmds.hotkeySet('User', edit = True, current = True)

    cmds.nameCommand('rb_xAxisSelectChannelCommand', ann = 'select x axis context in channel box', sourceType = 'python', c = 'python("rb_selectChannelCommand(axis = \'x\')")')
    cmds.nameCommand('rb_yAxisSelectChannelCommand', ann = 'select y axis context in channel box', sourceType = 'python', c = 'python("rb_selectChannelCommand(axis = \'y\')")')
    cmds.nameCommand('rb_zAxisSelectChannelCommand', ann = 'select z axis context in channel box', sourceType = 'python', c = 'python("rb_selectChannelCommand(axis = \'z\')")')

    # these have to reset since default Maya maps the key release
    cmds.hotkey(k = 'x', name = 'rb_xAxisSelectChannelCommand', releaseName = '')
    cmds.hotkey(k = 'c', name = 'rb_yAxisSelectChannelCommand', releaseName = '')
    cmds.hotkey(k = 'v', name = 'rb_zAxisSelectChannelCommand', releaseName = '')


    def rb_setupManipHotkeys():
    '''Overall setup. Use for button commands.
    '''

    rb_setupHotkeys()
    rb_setupChannelBoxSelectionScriptJob()

    #############################################
    # restore

    def rb_restoreChannelBox():
    '''Set everything back to vanilla Maya.
    '''
    global kChannelBoxScriptJob
    if kChannelBoxScriptJob is not None:
    try:
    cmds.scriptJob(kill = kChannelBoxScriptJob, f = True)
    except:
    cmds.warning("Script could not be killed: {0}".format(kChannelBoxScriptJob))

    cmds.channelBox(kChanBox, e = True, useManips = 'standard', hlc = kStandardColor)

    # make sure everything is set up correctly
    rb_setupManipHotkeys()

  • boby Thompson

    boby Thompson said 11 months ago:

    maya 2022 fix

     

     

    '''
    rb_manipHotkeys.py

    Maya script

    Description:
    Adds hotkeys to Maya to easily select the individual x, y, or z
    channel in the current manipulation mode. Adds different colours
    to the manipulation areas of the ChannelBox: red for translate,
    green for rotate and blue for scale.

    Author:
    Ron Bublitz
    Copyright (c) 2016. All rights reserved.

    Revisions:
    Oct 2016 Initial version

    '''


    import maya.cmds as cmds

    kChanBox = 'mainChannelBox'
    kTransColor = [0.604, 0.357, 0.357]
    kRotColor = [0.357, 0.604, 0.357]
    kScaleColor = [0.357, 0.596, 0.604]
    kNormalColor = [0.333, 0.349, 0.353]

    kStandardColor = [.322, .522, .651]
    kPrevMode = None
    kManipContexts = ['moveSuperContext', 'RotateSuperContext', 'scaleSuperContext']

    kChannelBoxScriptJob = None


    def rb_selectChannelCommand(axis = 'x', planeMode = False):
    '''Enters the correct manip context based on the axis specified.
    '''

    global kPrevMode
    global kChanBox

    # get current Context
    curContext = cmds.currentCtx()
    if curContext not in kManipContexts:
    curContext = kPrevMode
    else:
    kPrevMode = curContext

    axisList = ['x', 'y', 'z']
    if planeMode:
    axisList.remove(axis)
    else:
    axisList = list(axis)

    selList = cmds.ls(selection = True)
    if curContext == kManipContexts[0]:
    attr = '.t'
    elif curContext == kManipContexts[1]:
    attr = '.r'
    else:
    attr = '.s'

    plugList = list()
    for axis in axisList:
    plugList = plugList + [x + attr + axis for x in selList]

    cmds.channelBox(kChanBox, e = True, select = plugList, useManips = 'standard')


    def rb_channelBoxSelectionChanged():
    '''Changes the channel box highlight colour based on the channel selections.
    '''

    #global kChannelBoxScriptJob
    #if kChannelBoxScriptJob is None:
    # kChannelBoxScriptJob = cmds.scriptJob(event = ['ChannelBoxLabelSelected', rb_channelBoxSelectionChanged ], permanent = True )

    global kChanBox
    cbSelection = cmds.channelBox(kChanBox, q = True, selectedMainAttributes = True)
    if cbSelection is None:
    return

    channelType = set()
    for axis in ['tx', 'ty', 'tz']:
    for i in cbSelection:
    if i == axis:
    channelType.add('t')
    for axis in ['rx', 'ry', 'rz']:
    for i in cbSelection:
    if i == axis:
    channelType.add('r')
    for axis in ['sx', 'sy', 'sz']:
    for i in cbSelection:
    if i == axis:
    channelType.add('s')

    # check if there's one that one manip type
    if len(channelType) != 1:
    channelType = ['m']

    if 't' in channelType:
    cmds.channelBox(kChanBox, e = True, hlc = kTransColor)
    elif 'r' in channelType:
    cmds.channelBox(kChanBox, e = True, hlc = kRotColor)
    elif 's' in channelType:
    cmds.channelBox(kChanBox, e = True, hlc = kScaleColor)
    else:
    cmds.channelBox(kChanBox, e = True, hlc = kNormalColor)


    #############################################
    # setup

    def rb_setupChannelBoxSelectionScriptJob():
    global kChannelBoxScriptJob
    kChannelBoxScriptJob = cmds.scriptJob(event = ['ChannelBoxLabelSelected', rb_channelBoxSelectionChanged ], permanent = True )


    def rb_setupHotkeys():
    '''Adds the channel hotkeys to the 'x', 'c' and 'v' keyboard keys.
    If there is not a current user hotkey set, it will create it.
    '''
    # check if using the default hotkey set
    if cmds.hotkeySet(q = True, current = True) == 'Maya_Default':
    if not cmds.hotkeySet('User', q = True, exists = True):
    cmds.hotkeySet('User', current = True)
    else:
    cmds.hotkeySet('User', edit = True, current = True)

    cmds.nameCommand('rb_xAxisSelectChannelCommand', ann = 'select x axis context in channel box', sourceType = 'python', c = 'python("rb_selectChannelCommand(axis = \'x\')")')
    cmds.nameCommand('rb_yAxisSelectChannelCommand', ann = 'select y axis context in channel box', sourceType = 'python', c = 'python("rb_selectChannelCommand(axis = \'y\')")')
    cmds.nameCommand('rb_zAxisSelectChannelCommand', ann = 'select z axis context in channel box', sourceType = 'python', c = 'python("rb_selectChannelCommand(axis = \'z\')")')

    # these have to reset since default Maya maps the key release
    cmds.hotkey(k = 'x', name = 'rb_xAxisSelectChannelCommand', releaseName = '')
    cmds.hotkey(k = 'c', name = 'rb_yAxisSelectChannelCommand', releaseName = '')
    cmds.hotkey(k = 'v', name = 'rb_zAxisSelectChannelCommand', releaseName = '')


    def rb_setupManipHotkeys():
    '''Overall setup. Use for button commands.
    '''

    rb_setupHotkeys()
    rb_setupChannelBoxSelectionScriptJob()

    #############################################
    # restore

    def rb_restoreChannelBox():
    '''Set everything back to vanilla Maya.
    '''
    global kChannelBoxScriptJob
    if kChannelBoxScriptJob is not None:
    try:
    cmds.scriptJob(kill = kChannelBoxScriptJob, f = True)
    except:
    cmds.warning("Script could not be killed: {0}".format(kChannelBoxScriptJob))

    cmds.channelBox(kChanBox, e = True, useManips = 'standard', hlc = kStandardColor)

    # make sure everything is set up correctly
    rb_setupManipHotkeys()

  • roobot

    roobot said almost 7 years ago:

    Great Idea and can see me using once I get used to it - thanks for sharing :)

Post a review:

Rate this item: