Maya Python: Tips and Tricks

Level:
Intermediate
Software:
Maya
Language:
Python
Collection:
Archive
Instructor:
Chris Zurbrigg

Become a Patron!

Overview

This series of lessons covers a wide range of one-off topics that explain various Maya scripting tasks and answer frequently asked questions about Python scripting in Maya.

Videos

01 - Getting the Value of a MEL Global Variable

In this tips and tricks lesson, we look at how to get the value stored in a MEL global variable using Python.

02 - Listing All MEL Global Variable Names

In this tips and tricks lesson, we look at how to get a list of all the MEL global variable names in the current Maya session.

03 - Maya Environment Variables

In this tips and tricks lesson, we look at how to get and set Maya environment variables using Python.

04 - Modifying the Animation/Playback Time Range

In this tips and tricks lesson, we look at how to query and edit the animation and playback time ranges using Maya commands in Python.

05 - Finding User Directories

In this tips and tricks lesson, we look at how to find the Maya user directories (e.g. prefs, scripts, etc...) in the current Maya session.

06 - Understanding 'if __name__ == "__main__"'

In this tips and tricks lesson I discuss what the if __name__ == "__main__" statement means, and explain when and why it should be used in your Maya scripts.

07 - Loading and Unloading Plug-ins

In this tips and tricks lesson I demonstrate how to load and unload Maya plug-ins using Python. These code snippets can be used to create custom startup scripts allowing for different environments in Maya, as shelf buttons for development and more.

08 - Activating Common Tools (Select, Move, Rotate, Scale)

In this tips and tricks tutorial I demonstrate how to activate a tool in Maya using Python. Along the way you will see how to identify the context name of a tool and create helper functions to simplify the process.

09 - Determining if an Object Attribute Exists

In this tips and tricks lesson I discuss how to check if an attribute exists for a given object in Maya.

10 - Executing a Script on a Time Change

In this tips and tricks tutorial I demonstrate how to create a script job that executes a script whenever the current time changes.

11 - Finding the Version of Maya, Python, Qt and PySide

In this Maya Python Tips and Tricks tutorial I demonstrate how to query Maya for the current version of Maya, Python, Qt and PySide. Version information can be very useful for scripts that support multiple versions of Maya or for external tools that integrate with Maya.