Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Differences Between the C++ Maya API and Maya Python API | VSFX 705, Study notes of Typography

Material Type: Notes; Professor: Kesson; Class: Programming Concepts for Visual Effects; Subject: Visual Effects; University: Savannah College of Art and Design; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 08/04/2009

koofers-user-8xm
koofers-user-8xm 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
API Guide
Differences between the C++ Maya API and
Maya Python API
The Maya Python API is not an exact copy of the C++ Maya API. We have made changes to the
Python bindings for integration purposes.
No MString and MStringArray classes
We have removed the MString and MStringArray classes from the Maya Python API. Python
already has a very robust string implementation which makes ours unnecessary.
No MStatus class
We have removed the MStatus class. Python exceptions must be used instead of MStatus. See
previous examples.
Void* Pointers
The Maya API makes use of void *pointers in several places including messages. In the Maya
Python API, any Python object can be passed in place of a void* pointer.
Proxy Classes and Object Ownership
When creating a proxy class in a creator() function or any other function that returns the class
to Maya, you must call OpenMayaMPx.asMPxPtr() on the new object. This call transfers
ownership of the object to Maya. If this call is not made, then Python retains ownership and
can dereference the object and destroy it even though Maya may have a pointer to it.
Commands with Arguments must use an MSyntax
In C++, it is possible to use the argument parameter of MPxCommand::doIt() to find which
arguments have been entered. In Python, this does not work. Instead, you must use the
MSyntax and MArgParser classes to support arguments within a scripted MPxCommand.
Undo
It is possible to mix Maya Python API calls along with Maya command calls in the same script.
Undoing the operations of such a script will not be correct if the Maya Python API calls modify
the model and do not properly support undo using the MPxCommand class.
Modules versus Shared Libraries
When comparing these interfaces to the shared libraries we ship for the C++ Maya API, the
only difference is a new OpenMayaMPx module. This module contains the bindings for any proxy
or MPx class we provide.
Include files
The Maya API C++ include files are used to generate the bindings for the Maya Python API.
These files are not required when programming with the Maya Python API but are useful to see
pf2

Partial preview of the text

Download Differences Between the C++ Maya API and Maya Python API | VSFX 705 and more Study notes Typography in PDF only on Docsity!

API Guide

Differences between the C++ Maya API and

Maya Python API

The Maya Python API is not an exact copy of the C++ Maya API. We have made changes to the Python bindings for integration purposes.

No MString and MStringArray classes

We have removed the MString and MStringArray classes from the Maya Python API. Python already has a very robust string implementation which makes ours unnecessary.

No MStatus class

We have removed the MStatus class. Python exceptions must be used instead of MStatus. See previous examples.

Void* Pointers

The Maya API makes use of void pointers in several places including messages. In the Maya Python API, any Python object can be passed in place of a void pointer.

Proxy Classes and Object Ownership

When creating a proxy class in a creator() function or any other function that returns the class to Maya, you must call OpenMayaMPx.asMPxPtr() on the new object. This call transfers ownership of the object to Maya. If this call is not made, then Python retains ownership and can dereference the object and destroy it even though Maya may have a pointer to it.

Commands with Arguments must use an MSyntax

In C++, it is possible to use the argument parameter of MPxCommand::doIt() to find which arguments have been entered. In Python, this does not work. Instead, you must use the MSyntax and MArgParser classes to support arguments within a scripted MPxCommand.

Undo

It is possible to mix Maya Python API calls along with Maya command calls in the same script. Undoing the operations of such a script will not be correct if the Maya Python API calls modify the model and do not properly support undo using the MPxCommand class.

Modules versus Shared Libraries

When comparing these interfaces to the shared libraries we ship for the C++ Maya API, the only difference is a new OpenMayaMPx module. This module contains the bindings for any proxy or MPx class we provide.

Include files

The Maya API C++ include files are used to generate the bindings for the Maya Python API. These files are not required when programming with the Maya Python API but are useful to see

what is included or excluded in the bindings, since not all items in the C++ API are scriptable.