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 error handling in Maya

Most of these golden rules are true in Python in general, as well as most other programming languages with exceptions. However, using Python in Maya is a different environment. There are some additional tools and constraints available. In this section, we'll go through some of the unique problems we face in Maya, and what can be done to mitigate each problem.

Dealing with expensive and mutable state

The biggest problem with error handling in Maya is that its overall design significantly constrains the choices of any system built on top of it. Consider the following script that lowercases the fileTextureName (ftn) attribute of all the file nodes in the scene:

>>> for f in pmc.ls(type='file'): ... f.ftn.set(f.ftn.get().lower()) ...

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