ECToo / pymel

Automatically exported from code.google.com/p/pymel
0 stars 0 forks source link

How to use the overrideModifier #311

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, I run this script I got from this page (first example):

http://download.autodesk.com/global/docs/maya2013/en_us/PyMel/generated/function
s/pymel.core.windows/pymel.core.windows.overrideModifier.html

And it doesn't seem to work.

I'm using Maya 2014
I'm working on Windows 7 Professionnal
Service Pack1
64bit

I don't know which version of PyMEL I'm using. Where should I look for this?

The expected output is to get the "s" key, in maya, to act like the "Alt" key 
(navigation tool). It seems to have no effect other than giving me this message:

// Error: "overrideModifier -press Alt"; // 
// Error: Line 1.29: Syntax error // 
// Error: "overrideModifier -press Alt"; // 
// Error: Line 1.29: Syntax error // 

Here is the code I'm trying to run:

import pymel.core as pm

import maya.cmds as cmds

#    Example 1.
#
#    Map the "a" key such that it behaves just like the "Alt" key.
#
pm.nameCommand( 'alternateAltPressCommand', annotation='"Alternate Alt-press 
modifier key"', command='"overrideModifier -press Alt"' )
# Result: u'alternateAltPressCommand' #
pm.nameCommand( 'alternateAltReleaseCommand', annotation='"Alternate 
Alt-release modifier key"', command='"overrideModifier -release Alt"' )
# Result: u'alternateAltReleaseCommand' #
pm.hotkey( keyShortcut='s', name='alternateAltPressCommand' )
pm.hotkey( keyShortcut='s', releaseName='alternateAltPressCommand' )

Anyone has any idea?

Thanks.

Original issue reported on code.google.com by pgrenier...@gmail.com on 13 Dec 2013 at 2:40

GoogleCodeExporter commented 9 years ago
So, the problem here is that our examples are auto-generated off of Autodesk's 
examples, from here:

http://download.autodesk.com/global/docs/maya2013/en_us/PyMel/generated/function
s/pymel.core.windows/pymel.core.windows.overrideModifier.html

...which are also incorrect, in the same ways:

1) it's double-quoting the command
2) it's never assigning the release command, but just the press command twice.

This should "work":

nameCommand
    -annotation "Alternate Alt-press modifier key"
    -command "overrideModifier -press Alt"
    alternateAltPressCommand;
nameCommand
    -annotation "Alternate Alt-release modifier key"
    -command "overrideModifier -release Alt"
    alternateAltReleaseCommand;
hotkey -keyShortcut "a" -name "alternateAltPressCommand";
hotkey -keyShortcut "a" -releaseName "alternateAltReleaseCommand";

...however, it seems that you still can't use the overrideModifier command to 
affect the window-navigation behavior... =/

If you want to get either the example fixed, or make the overrideModifier 
affect window-navigation, you'll need to go through autodesk, so I'm closing 
this bug...

Original comment by elron...@gmail.com on 8 Feb 2014 at 3:49

GoogleCodeExporter commented 9 years ago
Thanks for helping!

Original comment by pgrenier...@gmail.com on 10 Feb 2014 at 1:22