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

Reading multiple types of files


Sometimes, you might want to have a single script that is capable of reading in multiple file types. For example, if you were building a complex system to build character rigs, you might want to have one custom format that holds information about default bone layouts and another type that stores information about animation settings, allowing the user to mix and match any two files.

In such cases, you might want your script to handle files with multiple extensions—one for each type of data. In this example, we'll look at how to do that by creating a script that can be used to read either FOO (our example text-based format) or FOB (our example binary format).

Getting ready

Make sure that you have at least one file of each type. For FOO files, you can just create them directly in a text editor. For FOB files, it's best to use the script in the writing binary files example.

How to do it...

Create a new file and add the following code:

import maya.cmds as cmds
import...