This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find out the name of the Maya GUI pane element under the cursor | |
string $pointedPaneElement = `paneLayout -paneUnderPointer`; | |
string $paneConfig = `paneLayout -query -configuration $pointedPaneElement`; | |
int $paneChildren = `paneLayout -query -numberOfChildren $pointedPaneElement`; | |
string $docTag = `paneLayout -query -docTag $pointedPaneElement`; | |
int $visible = `paneLayout -query -visible $pointedPaneElement`; | |
int $manage = `paneLayout -query -manage $pointedPaneElement`; | |
int $enable = `paneLayout -query -enable $pointedPaneElement`; | |
int $width = `paneLayout -query -width $pointedPaneElement`; | |
int $height = `paneLayout -query -height $pointedPaneElement`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find out the name of the Maya GUI pane element under the cursor | |
paneLayout -paneUnderPointer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Find out the current operating system platform. The platform local variable should be set to either "Windows", "Mac", or "Linux". | |
local platform = "" | |
if string.find(fusion:MapPath("Fusion:\\"), "Program Files", 1) then | |
-- Check if the OS is Windows by searching for the Program Files folder | |
platform = "Windows" | |
elseif string.find(fusion:MapPath("Fusion:\\"), "PROGRA~1", 1) then | |
-- Check if the OS is Windows by searching for the Program Files folder | |
platform = "Windows" | |
elseif string.find(fusion:MapPath("Fusion:\\"), "Applications", 1) then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MEL uses the pause command for sleeping the execution of the current script | |
pause -sec 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Capitalize the first letter of each word a string | |
textString = 'hello world!' | |
print textString.title() | |
# Output: Hello World | |
# Now try the title case conversion on elements in an array | |
cubicViews = [] | |
cubicViews.append('back') | |
cubicViews.append('bottom') | |
cubicViews.append('front') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add zero digit padding to an int value | |
global proc string pvr_zeroPadding(int $num, int $padding){ | |
// Tip from the blog post: http://ldunham.blogspot.ca/2012/01/melpython-adding-number-padding.html | |
int $lengthNum=size(string($num)); | |
string $padString; | |
if($lengthNum<$padding){ | |
for($i=0;$i<($padding-$lengthNum);$i++){ | |
$padString=$padString+"0"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int $startFrame = `getAttr "defaultRenderGlobals.startFrame"`; | |
int $endFrame = `getAttr "defaultRenderGlobals.endFrame"`; | |
// The $frameStep variable is used to implement frame skipping using the "By Frame" render settings attribute. | |
int $frameStep = `getAttr "defaultRenderGlobals.byFrameStep"`; | |
string $progressText = ""; | |
if($startFrame != $endFrame){ | |
// Show a rendering progress bar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Windows | |
system("echo %PATH%"); | |
// Mac & Linux | |
system("echo $PATH"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
print '[System ENV PATH] ' + os.environ['PATH'] | |
# Result: [System ENV PATH] /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check if Maya is running in Batch mode or with a GUI | |
# A return value of 1 means Batch Mode, 0 means GUI mode | |
def checkMayaGuiBatchMode(): | |
""" | |
Maya tip on detecting Maya Batch mode is from Michael Scarpa's blog post "MEL Sillyness": | |
http://www.scarpa.name/2010/12/16/mel-sillyness/ | |
""" | |
# Check if Maya is running in batch mode or with a GUI | |
import maya.OpenMaya |