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

Accessing geometric data in NURBS objects


In this example, we'll be looking at how to retrieve information about NURBS surfaces, starting with the number of control vertices (CVs) they contain.

However, the number of CVs in a NURBS object isn't quite as straightforward as the number of vertices in a polygonal object. Although polygonal objects are relatively simple, with their shape determined directly by the position of the vertices, the curvature at any given point of a NURBS object is influenced by multiple points. The exact number of points that influence a given area depends on the degree of the surface.

To see how this works, we'll create a script that will determine the total number of CVs in each direction (U and V) of a NURBS surface, and we'll look at how to select a particular CV.

Getting ready

Make sure that you have a scene containing at least one NURBS surface.

How to do it...

Create a new file, name it getNURBSinfo.py (or similar), and add the following code:

import maya.cmds as...