Skip to content

Instantly share code, notes, and snippets.

@jm991
Last active April 27, 2019 21:15
Show Gist options
  • Save jm991/29cc46b5b8e5fa4709ee4be0a7911095 to your computer and use it in GitHub Desktop.
Save jm991/29cc46b5b8e5fa4709ee4be0a7911095 to your computer and use it in GitHub Desktop.
Extensions for the default mel print statements to add new lines (println) and enable single line, formatted array printing (printarray)
//---------------------------------------------------------------------------------
// Source: https://gist.github.com/jm991/
// print methods for Maya 2017
// Author: John Mac
// Date: 10-29-2017
//
// Description:
// Extensions for the default mel print statements to add new lines (println) and enable single line, formatted array printing (printarray)
// https://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/Commands/print.html
// Installation:
// 1. Copy printextensions.mel to C:\Users\[USER]\Documents\maya\[MAYAVERSION]\prefs\scripts\jm991
// 2. Restart maya
global proc printarray( string $options[] )
{
int $i = 0;
int $numOptions = size($options);
print "[";
for ($option in $options)
{
print ($option);
if ($i < $numOptions - 1)
{
print ", ";
}
$i++;
}
print "]";
print "\r\n";
}
global proc println( string $option )
{
print $option;
print "\r\n";
}
/*
// MEL examples
$allDescendents = `listRelatives -allDescendents $node`;
print $allDescendents;
// head_geo
// body_geo
// legs_geo
printarray($allDescendents);
// [head_geo, body_geo, legs_geo]
*/
@jm991
Copy link
Author

jm991 commented Oct 30, 2017

Remove the ".c" from the filename when you download this (git doesn't support .mel syntax highlighting)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment