O'Reilly logo

Practical Maya Programming with Python by Robert Galanakis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Practical uses and improvements

We will close out the chapter by describing various uses for our automation system, as well as a few improvements.

Batch processing using Maya

The most obvious application for the automation system is batch processing. The following simple script will go through all files in the current directory, delete all unknown nodes, and save the file to a new path. It will print out the result of the processing for each file, and skip over errors.

import os import mayaserver.client as mayaclient execstr = """import pymel.core as pmc pmc.openFile(%r, force=True) for item in pmc.ls(type='unknown'): if item.exists(): pmc.delete(item) pmc.system.saveAs(%r)""" def process(socket, path): newpath = os.path.splitext(path)[0] + '_clean.ma' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required