Book Image

Maya Programming with Python Cookbook

By : Adrian Herbez
Book Image

Maya Programming with Python Cookbook

By: Adrian 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 (17 chapters)
Maya Programming with Python Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Opening a web page from script


If you find yourself writing a complex script, it can often be helpful to provide documentation for your script in the form of a web page. A great way to do that is to include an easy way to show that page to the user. In this example, we'll create a simple script that will open a given URL in the user's default web browser.

How to do it...

Create a new script and add the following code:

import maya.cmds as cmds

def showHelp():
    cmds.showHelp("http://www.adrianherbez.net", absolute=True)

showHelp()

Run the script, and you'll see the specified URL appear in your default browser.

How it works...

All we're really doing here is using the showHelp command. It's a bit misleading, as the showHelp command is also used to show Maya's documentation for a specific command. However, as long as you specify the absolute flag to true, you can pass in a full path to the URL you would like to open:

cmds.showHelp("http://www.adrianherbez.net", absolute=True)

Note that there are...