Skip to content

Instantly share code, notes, and snippets.

View AndrewHazelden's full-sized avatar

Andrew Hazelden AndrewHazelden

View GitHub Profile
@AndrewHazelden
AndrewHazelden / getMayaPaneInspector.mel
Created January 9, 2016 11:57
A MEL script to inspect the pane element under the cursor.
// 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`;
@AndrewHazelden
AndrewHazelden / getMayaPaneName.mel
Created January 9, 2016 11:33
A MEL script to find out the name of the panel GUI element under the cursor
// Find out the name of the Maya GUI pane element under the cursor
paneLayout -paneUnderPointer;
@AndrewHazelden
AndrewHazelden / blackmagic_design_fusion_dirname.lua
Created December 15, 2015 12:05
A LUA script for Blackmagic Design Fusion that will both check the current platform, and provide a file system related "dirname" function to trim a file path down to the base directory.
-- 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
@AndrewHazelden
AndrewHazelden / sleep.mel
Created December 12, 2015 14:45
A MEL command for sleeping for 10 seconds.
// MEL uses the pause command for sleeping the execution of the current script
pause -sec 1;
@AndrewHazelden
AndrewHazelden / title_case.py
Created December 9, 2015 11:35
A Python script for converting a text string into "Title Case" style formatting
# 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')
@AndrewHazelden
AndrewHazelden / padded_frame_number.mel
Last active December 9, 2015 11:39
A MEL script for generating a frame padded number. In this case the source value that is frame padded with leading zeros is the start frame value from the Maya Render Settings window
// 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";
@AndrewHazelden
AndrewHazelden / progress_bar_demo.mel
Last active February 4, 2022 20:19
A MEL script for updating a progress bar as a task is running. If the escape key is pressed the task stops and the progress bar is hidden.
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
@AndrewHazelden
AndrewHazelden / print_env.mel
Last active December 12, 2015 14:39
A MEL command for checking what the operating system's environment path variable is when launching child processes using system() on Windows.
// Windows
system("echo %PATH%");
// Mac & Linux
system("echo $PATH");
@AndrewHazelden
AndrewHazelden / print_env.py
Last active December 9, 2015 11:36
A Python script to check the system's environment path variable
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
@AndrewHazelden
AndrewHazelden / check_batch_mode.py
Last active May 9, 2023 07:38
A python script to check if Maya is running in Batch mode or with a GUI
# 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