How can I paint component selection?
I always seem to forget this: To pain-select polygonal components, enter the component mode you wish to pain (vertex, edge, face), and: RMB on the mesh Paint -> Paint SelectThere are two...
View ArticleUnderstanding MAYA_MODULE_PATH
Main Maya DocsAPI MFnPlugin docs, under 'modules'.Modules are a way to distribute custom plugins. They define paths to text files that specify directories where the plugins, and their dependencies...
View ArticleHow can I execute system commands and capture the results?
Via pure Python, you can use subprocess.Popen to do this. My Python Wiki has a subject covering this.In Maya though, PyMel makes this even easier via its pymel.util.shellOutput command (which appears...
View ArticleHow can I launch an external app, but not block Maya in the process?
This will open a Windows cmd shell from Maya, but not block Maya in the process:import subprocess subprocess.Popen("start cmd", shell=True)
View ArticleQuery Maya & Maya Python Executable Locations
Querying this in a Python script ran in Maya is pretty trivial: maya.exe and mayapy.exe (the Python executable) live in the same directory for Windows. You can also query where Python thinks its...
View ArticleHow I like my selection settings
These settings seem to change on me, so I need to get them all down in one place so I know how to set them back...
View ArticleMaya failing on maya.standalone import
Maya 2016 : I have batch tools that run, that execute this at the top of the Python module:# myModule.py if __name__ == "__main__": import maya.standalone maya.standalone.initialize(name='python') #...
View ArticleHow can I specify 'all keys' when cutting or pasting in Python?
In mel, when copying or pasting all keframes, the syntax is pretty simple (replace ... with the rest of the command code):cutKey -time ":" ... ; And even the Python command docs say this:-time ":" is a...
View ArticleHow can I find all reference edits, and remove them?
PyMel:This will filter the edits by type, and by namespace:import pymel.core as pm def removeRefEditCmd(editCommand, namespace=None): """ Tool to remove reference edits. editCommand : string : Valid...
View ArticleHow can I query the red/highlighted range on the timeslider?
import pymel.core as pm tc = pm.language.melGlobals["gPlayBackSlider"] first,last = pm.timeControl(tc, rangeArray=True, query=True)
View ArticleHow can I query what the highlighted range of the time slider is?
# Python code import maya.cmds as mc import maya.mel as mm # cast mel variable to Python: gPlayBackSlider = mm.eval("$g = $gPlayBackSlider") # Is anything highlighted? rangeHighlighted =...
View ArticleAPI: How can I author callbacks for Maya events?
The most common way to do this is via mel scriptJobs. But via the OpenMaya API, you can access many 'Message' classes that provide a lot more functionality to areas that scriptJob's don't provide.It...
View ArticleAPI: How can I make a transform?
(Referenced from 'Complete Maya Programming') Waaaay exciting! It should be noted that any time you use API calls outside of a plugin to modify the DG, you can't undo the operation.# Python code import...
View ArticleHow can I convert from string to int?
Some languages give you the ability to Boolean test strings: You can convert a string to a Boolean, and if the string has any characters, the bool = True. If the string is empty, the bool = False. How...
View ArticleHow can I add images to my UI, without hardcoding their paths?
It's fun to add images to your UI's, but the biggest problem is when you give your UI to someone else, usually the hard-coded paths to the imagery break. PythonOne nice thing about authoring modules in...
View ArticleHow can I author an undo context manager?
Starting with Python 2.5, they introduced the new with statement, which is known as a 'context manager'. See official...
View ArticleHow can I author an undo decorator?
A common problem I run into when coding in Python in Maya, is the ability to undo: Sometimes, and often this happens when issuing button commands via a UI, when the user wants to undo the last...
View ArticleHow can I make the Outliner in the Graph Editor not expand connections to...
This... 'annoyance' was introduced around Maya 2008 (+- a version?): If you had objectB.tx connected to objectA.tx, and objectB.tx was keyframed, and you opened the Graph Editor for objectA, you'd see...
View ArticleHow can I get a list of all incoming connections to a node?
Update: This is a perfect example of overengineering ;) I did all the below work before I realized there is a listHistory node, which does all this for you. Check it out...Say you have a list of Maya...
View ArticleServo Tools
Ran across this recently, had to make a note:Servo Tools for Maya"Servo Tools For Maya is a Python Plugin that sends rotational values over USB to the Arduino Micro Controller. These values are then...
View Article