Clean Namespaces (MEL Function)

Change Camera Marking Menu

This is a small tips for clear all namespaces in the maya scene. First copy the script bellow and save it as “bc_CleanAllNameSpace.mel” in any of your user script folder. Or you can download the script from here

[mel]
global proc string bc_CleanAllNameSpace()
{
string $bcReadOnlyNode[];

string $bcAllObjects[];
int $bcIndex;

$bcAllObjects = ls -allPaths;
$bcIndex = 0;
for($bcObject in $bcAllObjects)
{
$bcNewName = bc_CleanNameSpace($bcObject);
if(catchQuiet(rename $bcObject $bcNewName))
{
stringArrayInsertAtIndex($bcIndex, $bcReadOnlyNode, $bcObject);
$bcIndex++;
}
}
print $bcReadOnlyNode;
return “All the namespaces in the scene are cleaned”;
}

global proc string bc_CleanNameSpace(string $bcNodeName)
{
string $bcBuffer [];
string $bcNewName;
$bcBufferLen = tokenize $bcNodeName ":" $bcBuffer;

if($bcBufferLen > 1)
{
return $bcBuffer[$bcBufferLen – 1];
}
else
{
return $bcNodeName;
}
return “Its Not working”;
}
[/mel]

Create a shelf button using the following commands.

[mel]
source bc_CleanAllNameSpace.mel;
bc_CleanAllNameSpace();
[/mel]

Published by

Barish Chandran

Have got over 12 years of experience in Animation and VFX industry in Particle Effects, Lighting and Programming areas. I started my animation career as Dynamic FX artist and I have credit in more than 30 movie and CGI Series. Then started developing tools and programs for Animation. Now am working as Pipeline Software Developer Lead at MPC.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.