Reader small image

You're reading from  Maya Programming with Python Cookbook

Product typeBook
Published inJul 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781785283987
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Adrian Herbez
Adrian Herbez
author image
Adrian Herbez

Adrian Herbez is an accomplished software engineer and educator with a background in virtual worlds and gaming. He has worked as a web developer at Linden Lab (the creators of Second Life) and a senior software engineer at Sony Computer Entertainment, America, where he developed games and interactive content for PlayStation Home. He also served as the lead gameplay engineer for KIXEYE's War Commander. Adrian has also taught at the Academy of Art University in San Francisco in a number of different departments over the years, covering Maya, web development, and game programming. He is currently the cofounder and president of Jamwix, a game and media start-up. So far, Jamwix has released CineMagic: Hollywood Madness, a mobile game for iOS and Android as well as the first feature-length movie for virtual reality (The Banshee Chapter: Oculus Rift Edition). Adrian holds a master's degree in Fine Arts from the University of California, Irvine, from the Arts, Computation, and Engineering department, and has served as a juror for IndieCade, the international festival of independent gaming, for a number of years.
Read more about Adrian Herbez

Right arrow

Accessing documentation for a specific command


Maya is a complex tool, and it offers a wide range of functionality, all of it with corresponding commands that can be invoked via scripts. Each command has its own set of arguments, ranging from easily understood to quite cryptic.

When writing scripts for Maya (and as with any other kind of programming), it is vital to be able to find the appropriate documentation and to understand how to make sense of it.

How to do it...

Let's say that we want more information on a specific command, say the command to create a polygonal cube.

One way to view the help for the command is to use Maya's web-based command help, available by going to Help | Python Command Reference from within Maya. From there, you can either click on the "Polygons" subsection or use the search box.

There are a couple of other ways to get to the documentation for a command, though. You can also go directly to the documentation for a command from the Script Editor window. First, execute the corresponding action using Maya's interface, such as invoking the hotbox and choosing Create | Polygon Primitives | Cube.

That will cause the corresponding MEL command to be displayed in the output section of the Script Editor, in this case, "polyCube". From within the script editor, highlight the relevant line, and go to Help | Help on Selected Command. This will bring up a browser window with the documentation for that command. Note that it will default to the MEL version of the command; for the Python version, click on the "Python" link in the top-right corner of the window.

Finally, you can retrieve information about a command via Python directly using the help command. Try running the following:

print(cmds.help('polyCube'))

This will result in a list of the flags available for the given command, as well as the type of value that Maya expects for each, such as:

  -sx -subdivisionsX        Int

This means that there is a flag named "sx" or "subdivisionsX" that expects an integer value.

How it works...

For the most part, you'll want just the Python command reference open in a browser window while you work on developing your scripts. Good reference documents are key to writing good software, and you should get used to just keeping the references close at hand.

There's more...

You can also use the help command to invoke the web-based documentation for a given command directly, such as:

cmds.help('polyCube', doc=True, language='python')

This would bring up the web page containing the documentation for the Python version of the polyCube command. That's definitely a clunky way to access the help, but might be useful if you wanted to give the users of your script an easy way to refer to relevant documentation directly from your script's user interface.

Previous PageNext Page
You have been reading a chapter from
Maya Programming with Python Cookbook
Published in: Jul 2016Publisher: PacktISBN-13: 9781785283987
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.
undefined
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

Author (1)

author image
Adrian Herbez

Adrian Herbez is an accomplished software engineer and educator with a background in virtual worlds and gaming. He has worked as a web developer at Linden Lab (the creators of Second Life) and a senior software engineer at Sony Computer Entertainment, America, where he developed games and interactive content for PlayStation Home. He also served as the lead gameplay engineer for KIXEYE's War Commander. Adrian has also taught at the Academy of Art University in San Francisco in a number of different departments over the years, covering Maya, web development, and game programming. He is currently the cofounder and president of Jamwix, a game and media start-up. So far, Jamwix has released CineMagic: Hollywood Madness, a mobile game for iOS and Android as well as the first feature-length movie for virtual reality (The Banshee Chapter: Oculus Rift Edition). Adrian holds a master's degree in Fine Arts from the University of California, Irvine, from the Arts, Computation, and Engineering department, and has served as a juror for IndieCade, the international festival of independent gaming, for a number of years.
Read more about Adrian Herbez