You are previewing Maya Programming with Python Cookbook.
O'Reilly logo
Maya Programming with Python Cookbook

Book Description

Master complex workflows and conquer the world with Python and Maya

About This Book

  • Improve your modelling skills and reduce your scripting problems using Python in Maya

  • Learn to communicate with web applications using Python for easier team development

  • A quick and practical answer to every problem you can have whilst scripting in Maya with Python

  • Who This Book Is For

    This book is for Python developers who have just started scripting with Maya.

    What You Will Learn

  • Find out how to use Python scripting to automate tedious tasks

  • Create functional user interfaces to make scripts easy to share with others

  • Add new functionality to Maya via the power of scripting

  • Import and export arbitrary data into and out of Maya

  • Improve your workflow, and that of your team

  • Create custom create custom controls to make rigs that are easy to work with

  • Implement a system to render 3D assets for isometric games

  • Use script jobs to trigger actions automatically in response to user interaction

  • Open a command port to allow other applications to communicate with Maya

  • In Detail

    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.

    Style and approach

    This book is comprised of a set of practical recipes, grouped under specific topics, which can be referred to independently or in sequence. These recipes provide quick solutions to common problems, and cover most of the real-world scenarios that developers are likely to face when working with Maya.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Maya Programming with Python Cookbook
      1. Table of Contents
      2. Maya Programming with Python Cookbook
      3. Credits
      4. About the Author
      5. About the Reviewer
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Getting Started with Maya
        1. Introduction
        2. Using the script editor to investigate functionality
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Running code from the script editor
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Importing Maya's built-in Python functionality
          1. How to do it...
          2. How it works...
          3. There's more...
        5. Accessing documentation for a specific command
          1. How to do it...
          2. How it works...
          3. There's more...
        6. Understanding Create, Query, and Edit flags
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Adding custom folders to your script path
          1. How to do it...
          2. How it works...
          3. There's more...
        8. Writing and running an external script
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        9. Calling a MEL script with Python
          1. Getting ready
          2. How to do it...
          3. How it works...
      9. 2. Creating User Interfaces
        1. Introduction
        2. Making a basic window
          1. How to do it...
          2. How it works...
          3. There's more...
        3. Simple controls – making a button
          1. How to do it...
          2. How it works...
          3. There's more...
        4. Retrieving input from controls
          1. How to do it...
          2. How it works...
        5. Using classes to organize UI logic
          1. How to do it...
          2. How it works...
          3. There's more...
        6. Using nested layouts
          1. How to do it...
          2. How it works...
          3. There's more...
        7. Using tabs and scrolling
          1. How to do it...
          2. How it works...
          3. There's more...
        8. Adding menus to your UIs
          1. How to do it...
          2. How it works...
          3. There's more...
      10. 3. Working with Geometry
        1. Introduction
        2. Working with selected objects and checking node type
          1. How to do it...
          2. How it works...
          3. There's more...
        3. Accessing geometric data in polygonal models
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Accessing geometric data in NURBS objects
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Creating curves
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Creating new polygonal faces
          1. How to do it...
          2. How it works...
          3. There's more...
        7. Creating new modifiers (noise)
          1. How to do it...
          2. How it works...
          3. There's more...
        8. Creating novel primitives (tetrahedron)
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      11. 4. Giving Things a Coat of Paint – UVs and Materials
        1. Introduction
        2. Querying UV data
          1. Getting ready
          2. How to do it...
          3. How it works...
        3. Laying out UVs with Python
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Creating shading networks with code
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Applying shaders to objects
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Using shading nodes for non-shading tasks
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      12. 5. Adding Controls – Scripting for Rigging
        1. Introduction
        2. Creating skeletons with script
          1. How to do it...
          2. How it works...
          3. There's more...
        3. Setting up set-driven key relationships with script
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Adding custom attributes and locking and hiding attributes
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Setting up inverse kinematics (IK) with script
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      13. 6. Making Things Move – Scripting for Animation
        1. Introduction
        2. Querying animation data
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Working with animation layers
          1. How to do it...
          2. How it works...
          3. There's more...
        4. Copying animation from one object to another
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Setting keyframes
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Creating expressions via script
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      14. 7. Scripting for Rendering
        1. Introduction
        2. Creating and editing lights
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Creating GUI to control all lights
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Creating cameras from code
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Rendering a sprite sheet
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      15. 8. Working with File Input/Output
        1. Introduction
        2. Using the fileDialog2 command to navigate the file system
          1. How to do it...
          2. How it works...
          3. There's more...
        3. Reading text files
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Writing text files
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Writing binary data
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Reading binary data
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        7. Reading multiple types of files
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      16. 9. Communicating with the Web
        1. Introduction
        2. Opening a web page from script
          1. How to do it...
          2. How it works...
          3. There's more...
        3. Grabbing data from a server
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Working with XML data
          1. Getting ready
          2. How to do it...
          3. How it works...
        5. Working with JSON data
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Sending POST data to a web server from Maya
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      17. 10. Advanced Topics
        1. Introduction
        2. Wrapping Python functionality in MEL
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Creating custom tools using contexts
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Using script jobs to trigger custom functionality
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Using script nodes to embed code in scenes
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Combining script jobs and script nodes
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      18. Index