Chapter 10
Programming a Command
Author
Adam Mechtley
Project
Hello World command, Transform commands
Example Files
AR_HelloWorldCmd.py
AR_TransformCmd1.py
AR_TransformCmd2.py
AR_TransformCmd3.py
Synopsis
This chapter revisits Maya’s command engine and explains it in more detail, including its undo/redo mechanism. Readers walk through the basic parts of a command and learn how to write their own simple commands that parse arguments. The project centers around two versions of a transform command. The first version implements only query mode and prints information about a transform node in either world- or local-space. The second version implements undo/redo and create and edit modes for the same command.
Resources
Essential Mathematics for Games and Interactive Applications
Complete Maya Programming Vol. 2
Other Notes
For the sake of simplicity, Chapter 10 does not discuss unit types (MAngle, MDistance, etc.), though they are mentioned briefly in Chapter 12. For a more flexible, production-ready alternative to this chapter’s example, see AR_TransformCmd3.py.
Errata for the First Edition
None