Copyright (c) 2024
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Compatibility
-
2017, 2016
Operating Systems
History
Created: | 10/01/2016 |
Last Modified: | 10/02/2016 |
File Size: | 56 KB |
Keywords
Reviews Love it? Or maybe you want to share some creative ways you're putting this item to use.
-
boby Thompson said about 1 year ago:
maya 2022 fix
'''
rb_manipHotkeys.pyMaya script
Author:
Ron Bublitz
Copyright (c) 2016. All rights reserved.Revisions:
Oct 2016 Initial version
'''
import maya.cmds as cmdskChanBox = '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)
#############################################
# setupdef 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()#############################################
# restoredef 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 said about 1 year ago:
maya 2022 fix
'''
rb_manipHotkeys.pyMaya 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 cmdskChanBox = '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)
#############################################
# setupdef 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()#############################################
# restoredef 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 said about 7 years ago:
Great Idea and can see me using once I get used to it - thanks for sharing :)
Post a review:
Related Items:
-
Quadruped Path Animation System 1.1.4 for Maya (maya script)
$80.00 (USD) -
Animation Data Recovery 1.1.0 for Maya (maya script)
$100.00 (USD) -
BitCake Exporter - a Game Animation plugin 1.1.0 for Maya (maya script)
$20.00 (USD) -
JPose and Animation Tool for Maya 1.2.2 (maya script)
$20.00 (USD) -
SearchNPick Animation Picker 1.3.0 for Maya (maya script)
$100.00 (USD) -
White Tiger with animation 3D Model
$40.00 (USD)