Book Image

Maya Programming with Python Cookbook

By : Adrian Herbez
Book Image

Maya Programming with Python Cookbook

By: Adrian Herbez

Overview of this book

Maya is a 3D graphics and animation software, used to develop interactive 3D applications and games with stupendous visual effects. The Maya Programming with Python Cookbook is all about creating fast, powerful automation systems with minimum coding using Maya Python. With the help of insightful and essential recipes, this book will help you improve your modelling skills. Expand your development options and overcome scripting problems encountered whilst developing code in Maya. Right from the beginning, get solutions to complex development concerns faced when implementing as parts of build.
Table of Contents (17 chapters)
Maya Programming with Python Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Using script nodes to embed code in scenes


All of the examples we've seen so far exist as scripts, separate from the actual scene that they are run in. That's fine for tools, but means that if you create a script that is tightly tied to a particular scene (such as a custom control UI for a character rig), you have to be careful to make sure that the script file is always distributed along with the Maya file.

For such situations, Maya offers a better way. Script nodes can be used to bake scripts directly into a scene, allowing them to be run without any external dependencies. Furthermore, script nodes can be created with code.

In this example, we'll create a script that will prompt the user for a Python file, and will then create a script node with the contents of the file, and set it up so that the script will be executed each time the file is opened.

Getting ready

To use the script we'll be creating, we'll need to have a script ready to embed. For the sake of the example, I'll be using a simple...