Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Maya Programming with Python Cookbook

You're reading from  Maya Programming with Python Cookbook

Product type Book
Published in Jul 2016
Publisher Packt
ISBN-13 9781785283987
Pages 266 pages
Edition 1st Edition
Languages
Author (1):
Adrian Herbez Adrian Herbez
Profile icon Adrian Herbez

Table of Contents (17) Chapters

Maya Programming with Python Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
1. Getting Started with Maya 2. Creating User Interfaces 3. Working with Geometry 4. Giving Things a Coat of Paint – UVs and Materials 5. Adding Controls – Scripting for Rigging 6. Making Things Move – Scripting for Animation 7. Scripting for Rendering 8. Working with File Input/Output 9. Communicating with the Web 10. Advanced Topics Index

Working with animation layers


Maya offers the ability to create multiple layers of animation in a scene, which can be a good way to build up complex animation. The layers can then be independently enabled or disabled, or blended together, granting the user a great deal of control over the end result.

In this example, we'll be looking at how to examine the layers that exist in a scene, and building a script will ensure that we have a layer of a given name. For example, we might want to create a script that would add additional randomized motion to the rotations of selected objects without overriding their existing motion. To do this, we would want to make sure that we had an animation layer named randomMotion, which we could then add keyframes to.

How to do it...

Create a new script and add the following code:

import maya.cmds as cmds

def makeAnimLayer(layerName):

    baseAnimationLayer = cmds.animLayer(query=True, root=True)

    foundLayer = False

    if (baseAnimationLayer != None):
  ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}