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

Using script jobs to trigger custom functionality


Script jobs offer another alternative to explicitly calling scripts, or pressing buttons, to invoke your functionality. By using script jobs, it is possible to trigger custom functionality based on either a specific condition or a specific event.

In this example, we'll create a script job that will respond to the selection changed event by printing the name and type of the selected object to the console.

Getting ready

One of the things that makes script jobs so useful is the fact that they persist (as opposed to just running once). However, that can make developing scripts that use them a bit difficult, since if you change your code and re-run your script, you'll end up with multiple script jobs in your scene. For that reason, it's good to give yourself a way to easily clear out all existing script jobs. The following script will do just that:

import maya.cmds as cmds

def killAll():
    cmds.scriptJob(killAll=True, force=True)
    print('KILLED...
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}