Maya 2023 API Update guide

The guide is based on What’s New in the Maya Devkit in Maya 2023 with some extra info. For more details including commands and scripts changes, please checkout the documentation for more details.

Our Maya documentation team is also interested to know how impactful Developer documentation improvements have been over the past few releases. If you have a moment, please take this short survey to help us improve and know what is most important for you.

Building environments

The building environment remains unchanged.

Platform OS Compiler
Windows Windows 10 x64 Visual Studio 2019.7.8
Windows SDK Version 10.0.10586.0
Mac Mojave 10.14.x XCode 10.2.1
Linux CentOS/RHEL 7.x(x>=6) gcc 9.3.1 (DTS 9.1)

Back to top

Devkit changes

  • Alembic libraries have moved, using the find_alembic macro in your CMakeLists.txt files.
  • Devkit examples now require cmake version 3.13 or later to compile.
  • The py1ArrayAttrBlenderNode.py example has been added to demonstrate how to implement array attributes in a straightforward way.
  • The py1MoveTool.py example has been updated from using VP1 to using VP2, and updated to use Python API 2.0. It has been renamed to py2MoveTool.py.
  • The customImagePlane example has been updated to fix an issue where images were not animated when scrubbing.
  • The gpuCache example has been updated to use the new kSelectionHighlighting enum.
  • The rockingTransform example has been updated to use the new preRotation() method in MPxTransformationMatrix.
  • The offsetNode example has been updated to use the new GPU deformer API.
  • The apiMeshShape example has been updated to remove deprecated code and to fix a bug in the example.

Back to top

Python Changes

Python updated to version 3.9.7

Python has been updated to 3.9 from 3.7. Code compatibility is not guaranteed between these two version and you may encounter issues when porting your scripts from Python 3.7 to Python 3.9. There are several deprecated methods removed in Python 3.9. Consult What’s New in Python 3.8 and What’s New in Python 3.9 for details.

The ABI is not compatible between these 2 versions neither. Depending on which method is used (pybind11, swig, boost.python or CPython), it is necessary to review and recompile Python extensions.

PySide is now also built with Python 3.9.
Back to top

New Python site-packages directory

Maya will use a site-packages directory specific to its release version.

Operating system Path to new site-packages location
macOS Preferences/Autodesk/maya/2023/scripts/site-packages
linux /local/users//maya/2023/scripts/site-packages
Windows C:/Users//Documents/maya/2023/scripts/site-packages

This is an added directory. Packages will not be moved to this directory, and this directory will not replace any existing directories. However, packages in this directory will be prioritized over Maya’s own site-packages directory.

Use the pip —target option to install packages to this location:

mayapy -m pip install <package_name> --target <full_path_to_maya_2023_site-packages>

Back to top

Generating Python code from ui files using pyside2-uic

pyside2-uic and pyside2-rcc are now included with Maya.

Users can now use pyside2-uic to generate Python code from .ui files.

maya.api.OpenMaya.MFnMesh() handles empty meshes same as Python API 1.0 now.

Methods added to the Python API 2.0

The Python counterparts of the following C++ methods have been added to the Python API 2.0:

virtual void MPxNode::getCacheSetup(const MEvaluationNode&, MNodeCacheDisablingInfo&, MNodeCacheSetupInfo&, MObjectArray&) const
virtual void MPxNode::configCache(const MEvaluationNode&, MCacheSchema&) const
virtual MTimeRange MPxNode::transformInvalidationRange(const MPlug& source, const MTimeRange& input) const
bool MPxNode::hasInvalidationRangeTransformation() const
virtual void MPxGeometryOverride::configCache(const MEvaluationNode&, MCacheSchema&) const

Back to top

API Changes

Enhanced GPU deformer APIs

The MOpenCLUtils, MOpenCLKernelInfo, and MPxGPUStandardDeformer classes have been added.

One new method has been added to MGPUDeformerRegistrationInfo:

virtual bool isGeometryFilter() const

And four new methods have been added to MPxGPUDeformer:

static bool isBufferUpdateNeeded(const MOpenCLBuffer& buffer, const MEvaluationNode& evaluationNode, const MObject& attribute)
cl_int uploadFixedSetupData(const MString& name, MOpenCLBuffer& buffer, cl_int& errorCode, unsigned int* arrayLength)
static MFnGeometryData::SubsetState getSubsetState(MDataBlock& block, unsigned int multiIndex, MStatus* ReturnStatus = NULL)
static const char* className()

The offsetNode example has been updated to use these new classes and methods.

Two new methods, MColorPickerUtilities::applyViewTransform(), and MColorPickerUtilities::grabColor() and a new class MColorMixingSpaceHelper, have been added for creating a color managed color picker using the API.

MColorPickerUtilities::applyViewTransform (const MColor &inputColor, Direction direction)
MColor MColorPickerUtilities::grabColor(MStatus * returnedStatus = nullptr)

Improvement to the preference system

Three new methods have been added to MGlobal:

static bool initOptionVar(const MString& name, int value, const MString& category)
static bool initOptionVar(const MString& name, double value, const MString& category)
static bool initOptionVar(const MString& name, MString value, const MString& category)

MTimeSliderCustomDrawManager class has been added to the Maya API. This class provides a way to draw custom items on the timeline.

Three callback methods were added:

void setStopPrimitiveEditFunction(MCustomDrawID id, MSharedPtr< MStopPrimitiveEditingFct > fct)
void setStartPrimitiveEditFunction(MCustomDrawID id, MSharedPtr< MStartPrimitiveEditingFct > fct)
void setEditPrimitiveFunction(MCustomDrawID id, MSharedPtr< MEditPrimitiveFct > fct)

The three abstract classes, MStopPrimitiveEditingFct, MStartPrimitiveEditingFct, and MEditPrimitiveFct, were added to support these callbacks.

Three new selection levels have been added to the MIntersection::SelectionLevel() and MSelectionContext::SelectionLevel in OpenMayaRender

kFace, kEdge, kVertex were added. Plug-ins that test the selection level of a selection hit against the kComponent level should be updated to test against the three new levels instead.

reset() methods in MItMeshPolygon, MItMeshEdge, and MItMeshVertex have been modified to remove invalid component IDs automatically

getPreRotation() and preRotation() have been added to MPxTransform and MPxTransformationMatrix

The rockingTransform example has been modified to use this new functionality.

isProxy and proxied have been added to MPlug

snapToActive() added to MSelectionInfo

kSelectionHighlighting added to MGeometry::DrawMode

The gpuCache devkit example has been updated to use this new enum.

A DrawPass enum, beginDrawPass() and endDrawPass() have been added to MUIDrawManager

Two new parameters, inputColorSpace and alphaDiscardThreshold have been added to MUIDrawManager::setTexture()

inputColorSpace is the color space of the texture that will be used to create a shader override when converting texture color to render space color.

alphaDiscardThreshold controls the shader that draws textured UI objects. Any parts of the texture that have an alpha value lower than the threshold will not be drawn. A threshold of 0.0 means everything will be drawn while 1.0 means nothing will be.

DefaultMaterialFiltering, setDefaultMaterialHandling(), and getDefaultMaterialHandling() were added so that a MRenderItem can be filtered based on the default material setting of the viewport.

A new enum and three new methods have been added to MHWRender::MRenderItem.

MUint64 MRenderItem::InternalObjectId() const returns a unique identifier for a render item.

The default tolerance of MFnMesh::getPointsAtUV() was changed from 0 to 0.001. If no points are found, the method will no longer fail. Instead its arrays of points polygon IDs will be empty.

The methods edgeBorderInfo(), getUVBorderEdges(), and getMeshShellIds(), getRawUVs(), as well as the enum, BorderInfo, have been added to MFnMesh.

The BoolClassification enum indicates whether to use edge classification or normal classification when computing booleans between meshes using the booleanOps() method.

Four new overloaded create() and two new overloaded createInPlace() methods have been added to MFnMesh. The new methods mirror the mesh creation used by mayaAscii and mayaBinary file readers.

getMemberPaths() has been added to MFnSets to get an array of dagPaths that are members of the set.

isInCrashHandler() has been added to MGlobal to query where or not Maya has crashed.

isValidReference() added to MFnReference to validate a file reference before passing it to other methods, such as MFnReferemce::isLoaded(), to avoid triggering an exception.

uniqueName() added to MFnDependencyNode

devicePixelRatio() has been added to M3dView to return ratio of Qt logical pixels to viewport rendering pixels for the device.

isEmpty() added to MString

MStatus MFileIO::getReferenceNodes(const MString & fileName, MStringArray & nodes, bool dagPath) has been added to MFileIO

The return type of MIndexMapper::affectMap() has changed from MIntArray to MUintArray

Back to top


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading