Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Maya Programming with Python Cookbook
  • Table Of Contents Toc
Maya Programming with Python Cookbook

Maya Programming with Python Cookbook

By : Pankaj K P Singh, Herbez
4 (4)
close
close
Maya Programming with Python Cookbook

Maya Programming with Python Cookbook

4 (4)
By: Pankaj K P Singh, 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 (12 chapters)
close
close
11
Index

Wrapping Python functionality in MEL


Although Python is definitely the preferred way to go about scripting for Maya, there are some features that still require you to use MEL. We'll be seeing several of those features in this chapter, but first we'll need to look at how to call Python code from MEL.

Getting ready

First off, we'll need a Python script to call. You can either use something you've already written or make something new. For the sake of this example, I'll use a new script that simply creates a NURBS sphere at the origin, as follows:

# listing of pythonFromMel.py
import maya.cmds as cmds

def makeSphere():
    cmds.sphere()

How to do it...

In this example, we'll create an MEL script that will in turn call our Python script. Create a new file and add the following code, being sure to save it with a .mel extension. In this case, we'll create a file named melToPython.mel:

global proc melToPython()
{
    python "import pythonFromMel";
    python "pythonFromMel.makeSphere()";
}

Note that...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Maya Programming with Python Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon