ABSTRACT

So far we have introduced you to some basic Maya commands and the essentials for understanding data and variables in Python. Nevertheless, you still need some more fundamentals to start creating Python programs.

In this chapter, we walk through a simple texture-processing framework for Maya as we introduce functions, the building blocks for complex programs. We begin by learning how to declare a function in Python and return data from it. We then explore different methods for controlling code execution using Python’s sequence types and looping statements. Next, we demonstrate how to further control execution using Python’s conditional statements and branching capabilities. We conclude our exploration of functions by learning techniques for handling exit cases, including error and exception handling and returns. Finally, we incorporate all the major topics of this chapter into a set of functions that work with Maya commands to process textures.