Tips for effective production : some scripts to know... part. I

Hi everyone,

During animation-movies production, I had to face to some little tasks which were no creative, and took lot of time, because what you make in one scene, you have to repeat it for the next hundred one.

So I decided to work on little scripts and programs development, and I chose to show you few of these.

1 - Add proxies for all referenced object in a Maya scene

This MEL-Script will help you to complete your different versions of all referenced objects in your Maya scene. It's very useful when you have to switch between lowProxy files and HighProxy files for example.

This script is a "must have" when you have almost a hundred of objects referenced in different files.

This example use objects named with a suffix v001 and their HighProxy are named v002. We just need to use the substitution method on our references queries to load them.

"""Select all objects in the scene which contain "v001" in their namespace"""
select -r "*_v001:*";  
"""Begin of the process"""
global proc proxyAddition()  
{
    string $selectionList[] = `ls -sl -type "mesh"`;                                    """Create a stringArray with "v001" meshes names"""
    if(size($selectionList))                                                            """The process launches only if our stringArray is not empty"""
    {
        for($object in $selectionList) {
            string $currentRN = `referenceQuery -rfn $object`;                           """Collect infos about current references"""
            string $currentFilePath = `referenceQuery -filename $object`;
            string $currentNamespace = `referenceQuery -namespace $object`;
            if(endsWith($currentRN, "v001RN") == 1)
            {
                string $newRN = `substitute "v001RN" $currentRN "v002"`;                 """Start substitute method"""
                string $newFilePath = `substitute "v001" $currentFilePath "v002"`;
                string $newNamespace = `substitute "v001" $currentNamespace "v002"`;
                proxyAdd $currentRN $newFilePath "HD";                                     """Add new proxies using new vars"""
                print "Operation success !";

            }
        }
    }
    else
    {
        warning "There's no v001 objects in the scene.";
    }
}
proxyAddition; """Launch the process"""

You are not forced to use the first line of the script, like that you can just add proxies for selected referenced objects !

You guessed pathfile of the referenced files and proxies have to be similar in this case (v001 files and v002 files in the same directory).

But you can adapt it for your pipeline of course, by increasing substitution method. For example :

string $newFilePathDir = `substitute "lowPolyDir" $newFilePath "highPolyDir"`;  

All referenced objects which are placed in the directory "lowPolyDir" (it could be anywhere in the arborescence) will have their proxies by using the directory "highPoly".

The HD argument :

In the script you can see an argument which has HD value. It's just used for proxyTag of the new proxy (HD is easier to understand than v002).

Next tip will be a kind of a follow of this first one : a QuickProxySwitch MEL-script.