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' ...

Get Practical Maya Programming with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.