예제 #1
0
def override_pickwalk():
    '''Change the default pickWalk command to prefer Pickrunner.

    If the object that the user is pickWalking from has any defined Pickrunner
    settings, read them and use them.

    If there's no mapping for the pickWalk direction defined for Pickrunner,
    just pickWalk instead.

    '''
    command = pm.nameCommand(
        'pickrunner_Up',
        command='python("from pickrunner import mayarunner;mayarunner.do_pickrun_motion(\'up\')")',
        annotation='Use Pickrunner to go up')
    pm.hotkey(keyShortcut='Up', name=command)

    command = pm.nameCommand(
        'pickrunner_Down',
        command='python("from pickrunner import mayarunner;mayarunner.do_pickrun_motion(\'down\')")',
        annotation='Use Pickrunner to go down')
    pm.hotkey(keyShortcut='Down', name=command)

    command = pm.nameCommand(
        'pickrunner_Left',
        command='python("from pickrunner import mayarunner;mayarunner.do_pickrun_motion(\'left\')")',
        annotation='Use Pickrunner to go left')
    pm.hotkey(keyShortcut='Left', name=command)

    command = pm.nameCommand(
        'pickrunner_Right',
        command='python("from pickrunner import mayarunner;mayarunner.do_pickrun_motion(\'right\')")',
        annotation='Use Pickrunner to go right')
    pm.hotkey(keyShortcut='Right', name=command)
예제 #2
0
 def __createShortcut__(self, function):
     if function=='copy':
         pmc.nameCommand( 'LH_copySkinWeight', annotation='copy weight data', command = 'python( "copyPasteWeightUIInst.__copyWeight__()" );')
         pmc.hotkey( keyShortcut=self.ui['txfCopy'].getText()[0], ctl=self.ui['chbCoCtrl'].getValue(), alt=self.ui['chbCoAlt'].getValue(), name='LH_copySkinWeight' )
         vp.vPrint('Copy hotkey is done', 2)
     
     elif function=='paste':
         pmc.nameCommand( 'LH_pasteSkinWeight', annotation='paste weight data', command = 'python( "copyPasteWeightUIInst.__pasteWeight__()" );')
         pmc.hotkey( keyShortcut=self.ui['txfPaste'].getText()[0], ctl=self.ui['chbPaCtrl'].getValue(), alt=self.ui['chbPaAlt'].getValue(), name='LH_pasteSkinWeight' )
         vp.vPrint('Paste hotkey is done', 2)
예제 #3
0
def register_cmds(mobject):
	deregister_cmds(mobject)
	plugin = OpenMayaMPx.MFnPlugin(mobject)
	for command_info in CMDS:
		try:
			plugin.registerCommand(command_info.name, command_info.cmd_creator)
			pm.nameCommand(command_info.name, ann=command_info.name, command = command_info.name)
			if command_info.key_binding != NULL_KEY_BINDING:
				pm.hotkey(keyShortcut = command_info.key_binding, name=command_info.name, ctrlModifier=command_info.ctrl, altModifier=command_info.alt)
			print "Registered command " + command_info.name
		except:
			print "Failed to register command " + command_info.name
예제 #4
0
def hotkeys():
    """
    Creates hotkeys that make use of piper scripts.
    """
    # make a custom key set since Maya's default is locked.
    if not pm.hotkeySet(pcfg.hotkey_set_name, exists=True):
        pm.hotkeySet(pcfg.hotkey_set_name, source='Maya_Default')

    # set the current hotkey set to be piper's hotkey set
    pm.hotkeySet(pcfg.hotkey_set_name, current=True, edit=True)

    # CLEAR EXISTING HOTKEY(s)
    # if key is being used, clear it so we can assign a new one.
    if pm.hotkeyCheck(key='c', alt=True):
        pm.hotkey(k='c', alt=True, n='', rn='')

    # ASSIGN NEW HOTKEY(s)
    # create command and assign it to a hotkey
    python_command = 'python("import piper.mayapy.util as myu; myu.cycleManipulatorSpace()")'
    command = pm.nameCommand('cycleManipulator',
                             command=python_command,
                             annotation='Cycles Manipulator Space')
    pm.hotkey(keyShortcut='c', alt=True, name=command)

    pm.displayInfo('Assigned Piper Hotkeys')
예제 #5
0
def setHotkeys():
    if pm.hotkeySet('Custom', q=1, exists=1):
        pm.hotkeySet('Custom', edit=1, current=1)
    else:
        pm.hotkeySet('Custom', source="Maya_Default", current=1)
    if pm.windows.runTimeCommand(uca=1, q=1):
        for ca in pm.windows.runTimeCommand(uca=1, q=1):
            if ca.find('Custom') == -1:
                pm.windows.runTimeCommand(ca, edit=1, delete=1, s=1)
    import_command = "import PipelineTools.utilities as ul\nreload(ul)"
    commands_dict = {}
    skin_utilities_dict = {}
    skin_utilities_dict['BindPose'] = (
        "GoToBindPose",  #Command
        "BindPose",  #Command Name
        ['2', True, True, False]  # Key, Ctrl, Alt, Shift
    )
    skin_utilities_dict['PaintWeight'] = (
        "artAttrSkinToolScript 3",  #Command
        "PaintWeight",  #CommandName
        ['1', True, True, False]  # Key, Ctrl, Alt, Shift
    )
    weight_tick = 5
    weight_value = 1.0 / (weight_tick - 1)
    for i in range(weight_tick):
        format_value = '%04.2f' % (weight_value * i)
        format_value = "".join(format_value.split('.'))
        skin_utilities_dict['SetWeight%s' % (format_value)] = ("\n".join([
            import_command,
            "ul.skin_weight_setter(skin_value=%s, normalized=False)" %
            (weight_value * i)
        ]), "SetWeightTo%s" % (format_value), [
            "%d" % (i + 1), False, True, False
        ])
    commands_dict['skin_tool'] = skin_utilities_dict
    nameCommandList = []
    for category in commands_dict:
        for command in commands_dict[category]:
            if pm.runTimeCommand(command, q=1, exists=1):
                pm.runTimeCommand(command, edit=1, delete=1, s=1)
            pm.runTimeCommand(command,
                              category=category,
                              command=commands_dict[category][command][0])
            nameCommand = pm.nameCommand(
                command + "NameCommand",
                ann=commands_dict[category][command][1],
                c=command)
            nameCommandList.append(
                (nameCommand, commands_dict[category][command][2]))
    for nc in nameCommandList:
        print nc
        if nc[1][0]:
            print "hotKey is %s" % nc[1][0]
            pm.hotkey(keyShortcut=nc[1][0],
                      ctl=nc[1][1],
                      alt=nc[1][2],
                      sht=nc[1][3],
                      n=nc[0])
예제 #6
0
def create_marking_menu_command(rtc, command):
    if pm.runTimeCommand(rtc, exists=True):
        pm.runTimeCommand(rtc, edit=True, delete=True)
    pm.runTimeCommand(rtc,
                      category=k.MarkingMenus.category,
                      command=k.MarkingMenus.cmd_form.format(command),
                      commandLanguage="python")
    nc = pm.nameCommand(rtc + "NameCommand",
                        annotation=rtc + 'NameCommand generated',
                        command=rtc)
    return nc
예제 #7
0
def create_hotkey(command_hotkey,
                  command=None,
                  name=None,
                  mel=False,
                  maya_default=False):
    # prev_cmd = pm.hotkey(cmdHotkey, query=True, name=True)
    nice_name_hotkey = command_hotkey
    if pm.hotkeySet(q=True, current=True) == "Maya_Default":
        pm.hotkeySet("b_tools", current=True, source='Maya_Default')

    if not name:
        name = command.split(".")[-1]

    if maya_default:
        nc = name
    else:
        rtc = name
        nc = name + "NameCommand"

        if pm.runTimeCommand(rtc, exists=True):
            pm.runTimeCommand(rtc, edit=True, delete=True)

        command_language = "python"
        if mel:
            command_language = "mel"

        rtc = pm.runTimeCommand(rtc,
                                annotation=name + ' Hotkey generated',
                                category=k.Module.name,
                                command=command,
                                commandLanguage=command_language)
        nc = pm.nameCommand(nc,
                            annotation=name + ' nameCommand generated',
                            command=rtc)

    hotkey_params = dict()
    hotkey_params["name"] = nc

    if "alt" in command_hotkey.lower():
        hotkey_params["altModifier"] = True
        command_hotkey = command_hotkey.lower().replace("alt+", "")

    if "ctrl" in command_hotkey.lower():
        hotkey_params["ctrlModifier"] = True
        command_hotkey = command_hotkey.lower().replace("ctrl+", "")

    if "shift" in command_hotkey.lower():
        hotkey_params["shiftModifier"] = True
        command_hotkey = command_hotkey.lower().replace("shift+", "")

    hotkey_params["keyShortcut"] = command_hotkey.lower()
    pm.hotkey(**hotkey_params)
    print "       {}        {}".format(nice_name_hotkey, rtc)
예제 #8
0
def override_pickwalk():
    '''Change the default pickWalk command to prefer Pickrunner.

    If the object that the user is pickWalking from has any defined Pickrunner
    settings, read them and use them.

    If there's no mapping for the pickWalk direction defined for Pickrunner,
    just pickWalk instead.

    '''
    command = pm.nameCommand(
        'pickrunner_Up',
        command=
        'python("from pickrunner import mayarunner;mayarunner.do_pickrun_motion(\'up\')")',
        annotation='Use Pickrunner to go up')
    pm.hotkey(keyShortcut='Up', name=command)

    command = pm.nameCommand(
        'pickrunner_Down',
        command=
        'python("from pickrunner import mayarunner;mayarunner.do_pickrun_motion(\'down\')")',
        annotation='Use Pickrunner to go down')
    pm.hotkey(keyShortcut='Down', name=command)

    command = pm.nameCommand(
        'pickrunner_Left',
        command=
        'python("from pickrunner import mayarunner;mayarunner.do_pickrun_motion(\'left\')")',
        annotation='Use Pickrunner to go left')
    pm.hotkey(keyShortcut='Left', name=command)

    command = pm.nameCommand(
        'pickrunner_Right',
        command=
        'python("from pickrunner import mayarunner;mayarunner.do_pickrun_motion(\'right\')")',
        annotation='Use Pickrunner to go right')
    pm.hotkey(keyShortcut='Right', name=command)
예제 #9
0
파일: pickwalk.py 프로젝트: loichuss/maya
def overridePickWalkUI():
    pmc.nameCommand( 'LH_pickwalkUp', annotation='pick walk Up', command = 'python( "pickWalkUp()" );')
    pmc.hotkey( keyShortcut='Up', name='LH_pickwalkUp' )
    vp.vPrint('override pick walk Up is done', 2)
    
    
    pmc.nameCommand( 'LH_pickwalkDown', annotation='pick walk Down', command = 'python( "pickWalkDown()" );')
    pmc.hotkey( keyShortcut='Down', name='LH_pickwalkDown' )
    vp.vPrint('override pick walk Down is done', 2)
    
    pmc.nameCommand( 'LH_pickwalkLeft', annotation='pick walk Left', command = 'python( "pickWalkLeft()" );')
    pmc.hotkey( keyShortcut='Left', name='LH_pickwalkLeft' )
    vp.vPrint('override pick walk Left is done', 2)
    
    pmc.nameCommand( 'LH_pickwalkRight', annotation='pick walk Right', command = 'python( "pickWalkRight()" );')
    pmc.hotkey( keyShortcut='Right', name='LH_pickwalkRight' )
    vp.vPrint('override pick walk Right is done', 2)
예제 #10
0
def modelling_hotkeys(modelling_toolkit=True):
    """
    Bevel, Extrude and Split
    are mapped to b, n, m

    Maya 2014 is required to use the modelling Toolkit

    @param modelling_toolkit: hotkeys use modelling toolkit commands
    """
    if not pm.versions.current() >= pm.versions.v2014:
        raise ValueError

    if modelling_toolkit:
        pm.nameCommand('MT_Bevel', annotation='Modelling Toolkit Bevel', command='nexOpt -e manipType bevel;')
        pm.nameCommand('MT_Extrude', annotation ="Modelling Toolkit Extrude", command = 'nexOpt -e manipType extrude;')
        pm.nameCommand('MT_MultiCut', annotation ="Modelling Toolkit MultiCut", command = 'nexOpt -e manipType cut;')

        commands = [("b", "MT_Bevel"), ("n", "MT_Extrude"), ("m", "MT_MultiCut")]
    else:
        commands = [("b", "BevelPolygonNameCommand"), ("n", "PolyExtrude"), ("m", "SplitPolygonTool")]

    set_hotkeys(commands)
예제 #11
0
def registerMenuHotkeys(menuName,
                        hotkey,
                        importCmd=None,
                        preBuildCmd=None,
                        secondaryCmd=None,
                        annotation=None):
    """
    Setup hotkeys for builds and removing marking menus on hotkey press and release.

    Args:
        menuName: A string name of the menu for which to create hotkeys
        hotkey: A string representing the hotkey to use for the menu, e.g. 'Alt+Shift+Q'
        importCmd: String formatted python for any imports required by preBuild or secondary commands
        preBuildCmd: String formatted python that is called before building the menu
        secondaryCmd: String formatted python to be called on release if the menu is not invoked
        annotation: A string description of the menu to use when building the runTimeCommand
    """
    # the format for runtime command ids
    rtCmdIdFmt = "quickMenus_{0}_{1}"
    # the format for named command ids
    namedCmdIdFmt = "quickMenus_{0}_{1}_nameCmd"
    # get kwargs from hotkey string
    keyKwargs = utils.getHotkeyKwargs(hotkey)

    # shared kwargs for all runtime commands
    runTimeKwargs = {
        "annotation": annotation,
        "category": "Custom Scripts.quickmenus",
        "cl": "python",
    }

    # clean prebuild and secondary commands
    importCmd = importCmd if importCmd else ""
    preBuildCmd = preBuildCmd if preBuildCmd else ""
    secondaryCmd = secondaryCmd if secondaryCmd else "pass"

    # create run time commands
    buildCmd = BUILD_MENU_CMD.format(menuName=menuName,
                                     importCmd=importCmd,
                                     preBuild=preBuildCmd,
                                     secondary=secondaryCmd)
    destroyCmd = DESTROY_MENU_CMD.format(menuName=menuName,
                                         importCmd=importCmd,
                                         preBuild=preBuildCmd,
                                         secondary=secondaryCmd)

    buildRtCmdId = rtCmdIdFmt.format("build", menuName)
    if pm.runTimeCommand(buildRtCmdId, q=True, ex=True):
        pm.runTimeCommand(buildRtCmdId, e=True, delete=True)
    pm.runTimeCommand(buildRtCmdId, c=buildCmd, **runTimeKwargs)

    buildNameCmdId = namedCmdIdFmt.format("build", menuName)
    pm.nameCommand(buildNameCmdId,
                   c=buildRtCmdId,
                   ann=buildRtCmdId + " Named Command")

    destroyRtCmdId = rtCmdIdFmt.format("destroy", menuName)
    if pm.runTimeCommand(destroyRtCmdId, q=True, ex=True):
        pm.runTimeCommand(destroyRtCmdId, e=True, delete=True)
    pm.runTimeCommand(destroyRtCmdId, c=destroyCmd, **runTimeKwargs)

    destroyNameCmdId = namedCmdIdFmt.format("destroy", menuName)
    pm.nameCommand(destroyNameCmdId,
                   c=destroyRtCmdId,
                   ann=destroyRtCmdId + " Named Command")

    # make sure we're in an editable hotkey set in >2017
    _switchToNonDefaultHotkeySet()

    pm.hotkey(name=buildNameCmdId, **keyKwargs)
    pm.hotkey(releaseName=destroyNameCmdId, **keyKwargs)
예제 #12
0
def setHotkeys():
    """Create RuntimeCommand for Hair Ops """
    if pm.hotkeySet('HairOps', q=1, exists=1):
        pm.hotkeySet('HairOps', edit=1, current=1)
    else:
        pm.hotkeySet('HairOps', source="Maya_Default", current=1)
    if pm.windows.runTimeCommand(uca=1, q=1):
        for ca in pm.windows.runTimeCommand(uca=1, q=1):
            if ca.find('HairOps') == -1:
                pm.windows.runTimeCommand(ca, edit=1, delete=1, s=1)
    importCommand = "import MeshHairTool.hairOps as ho\nreload(ho)"
    commandsDict = {}
    hairCommands_dict = {}
    hairCommands_dict["MakeHair"] = ("\n".join(
        [importCommand,
         "ho.makeHairMesh()"]), "Make Hair", ["", False, False, False])
    hairCommands_dict['MakeHairUI'] = ("\n".join(
        [importCommand,
         "ho.makeHairUI()"]), "Make Hair UI", ["", False, False, False])
    hairCommands_dict['DuplicateHair'] = ("\n".join([
        importCommand, "ho.dupHairMesh()"
    ]), "Duplicate Hair along with Controls", ["#", False, False, False])
    hairCommands_dict['MirrorHair'] = ("\n".join([
        importCommand, "ho.dupHairMesh(mirror=True)"
    ]), "Mirror Hair along with Controls", ["%", False, False, False])
    hairCommands_dict['SelectHair'] = ("\n".join([
        importCommand, "ho.pickWalkHairCtrl(d='up')"
    ]), "Select Hair Control Root", ["3", False, True, False])
    hairCommands_dict['SelectAllControls'] = ("\n".join([
        importCommand, "ho.selHair(selectAll=True)"
    ]), "Select All Controls of Hair", ["4", False, True, False])
    hairCommands_dict['SetHairPivotTip'] = ("\n".join([
        importCommand, "ho.selHair(setPivot=True,pivot=-1)"
    ]), "set Hair Control Root Pivot to Root", ["5", False, True, False])
    hairCommands_dict['SplitHairControlUp'] = ("\n".join([
        importCommand, "ho.splitHairCtrl(d='up')"
    ]), "Add a Hair Control Toward Tip", ["2", True, True, False])
    hairCommands_dict['SplitHairControlDown'] = ("\n".join([
        importCommand, "ho.splitHairCtrl(d='down')"
    ]), "Add a Hair Control Toward Root", ["1", True, True, False])
    hairCommands_dict['DeleteHairAll'] = ("\n".join([
        importCommand, "ho.delHair()"
    ]), "Delete Hair with its controls", ["$", False, False, False])
    hairCommands_dict['DeleteHairControl'] = ("\n".join([
        importCommand, "ho.delHair(keepHair=True)"
    ]), "Delete Hair controls but keep Hair Mesh", ["", False, False, False])
    hairCommands_dict['DeleteControlsUp'] = ("\n".join([
        importCommand, "ho.delHair(dType='above', keepHair=True)"
    ]), "Delete All Controls From Select to Tip", ["4", True, True, False])
    hairCommands_dict['DeleteSelectControl'] = ("\n".join([
        importCommand, "ho.delHair(dType='self', keepHair=True)"
    ]), "Delete Select Control", ["3", True, True, False])
    hairCommands_dict['DeleteControlsDown'] = ("\n".join([
        importCommand, "ho.delHair(dType='below', keepHair=True)"
    ]), "Delete All Controls From Select to Root", ["5", True, True, False])
    hairCommands_dict['RebuildControlsUp'] = ("\n".join([
        importCommand, "ho.splitHairCtrl(d='up')"
    ]), "rebuild All Controls From Select to Tip", ["", False, False, False])
    hairCommands_dict['RebuildSelectControl'] = ("\n".join([
        importCommand, "ho.splitHairCtrl(d='self')"
    ]), "rebuild Select Control", ["", False, False, False])
    hairCommands_dict['RebuildControlsDown'] = ("\n".join([
        importCommand, "ho.splitHairCtrl(d='down')"
    ]), "rebuild All Controls From Select to Root", ["", False, False, False])
    hairCommands_dict['PickWalkHideRight'] = ("\n".join([
        importCommand, "ho.pickWalkHairCtrl(d='right')"
    ]), "Pick Walk Right and hide last Select Control",
                                              ["2", False, True, False])
    hairCommands_dict['PickWalkAddRight'] = ("\n".join([
        importCommand, "ho.pickWalkHairCtrl(d='right',add= True)"
    ]), "Pick Walk Right and add to last Select Control",
                                             ["@", False, True, False])
    hairCommands_dict['PickWalkHideLeft'] = ("\n".join([
        importCommand, "ho.pickWalkHairCtrl(d='left')"
    ]), "Pick Walk Left and hide last Select Control",
                                             ["1", False, True, False])
    hairCommands_dict['PickWalkAddLeft'] = ("\n".join([
        importCommand, "ho.pickWalkHairCtrl(d='left',add= True)"
    ]), "Pick Walk Left and add to last Select Control",
                                            ["!", False, True, False])
    hairCommands_dict['HideAllHairCtrls'] = ("\n".join([
        importCommand, "ho.ToggleHairCtrlVis(state='hide')"
    ]), "Hide All Hair Controls", ["t", False, False, True])
    hairCommands_dict['ShowAllHairCtrls'] = ("\n".join([
        importCommand, "ho.ToggleHairCtrlVis(state='show')"
    ]), "Show All Hair Controls", ["t", False, True, True])
    commandsDict['HairOps'] = hairCommands_dict
    nameCommandList = []
    for category in commandsDict:
        for command in commandsDict[category]:
            if pm.runTimeCommand(command, q=1, exists=1):
                pm.runTimeCommand(command, edit=1, delete=1, s=1)
            pm.runTimeCommand(command,
                              category=category,
                              command=commandsDict[category][command][0])
            nameCommand = pm.nameCommand(
                command + "NameCommand",
                ann=commandsDict[category][command][1],
                c=command)
            nameCommandList.append(
                (nameCommand, commandsDict[category][command][2]))
    for nc in nameCommandList:
        print nc
        if nc[1][0]:
            print "hotKey is %s" % nc[1][0]
            pm.hotkey(keyShortcut=nc[1][0],
                      ctl=nc[1][1],
                      alt=nc[1][2],
                      sht=nc[1][3],
                      n=nc[0])