Evgeniy Zaitsev Technical Artist


Generate random uv’s Maya Python API

Quick example working with OpenMaya.MFnMesh setUV and assignUV.
Limitation : works only on objects with no construction history.
Download : apiGenerateUV.zip


Convert Vertex Normals to Soft/Hard Edges using Maya Python API

Download : vtxNormalsToSoftHardEdges.zip

import vtxNormalsToSoftHardEdges; vtxNormalsToSoftHardEdges.convertNormals();


get MDagPath() from MObject()

Quick example

import maya.OpenMaya as OpenMaya

m_obj       = OpenMaya.MObject() # should get from any code above
m_dagPath   = OpenMaya.MDagPath()
if m_obj.hasFn( OpenMaya.MFn.kDagNode ):
    OpenMaya.MDagPath.getAPathTo( m_obj, m_dagPath )
    print( m_dagPath.fullPathName() )

Traversing whole scene file Maya Python API

Quick example

import maya.OpenMaya as OpenMaya

m_iterator = OpenMaya.MItDag( OpenMaya.MItDag.kDepthFirst )
while not m_iterator.isDone():
	m_obj   = m_iterator.currentItem()
	m_objFn = OpenMaya.MFnDagNode( m_obj )
	#if ( OpenMaya.MFn.kMesh == m_obj.apiType() ):
	print( m_objFn.fullPathName() )


Get all extra attributes Maya Python API

Select the node and run:

m_list = getAllExtraAttributes()
print( m_list )


Get all attributes from the kFileTexture node Maya Python API

import maya.OpenMaya as OpenMaya

m_iterator = OpenMaya.MItDependencyNodes( OpenMaya.MFn.kFileTexture )
m_nodeFn   = OpenMaya.MFnDependencyNode()

while not m_iterator.isDone():
    m_object = m_iterator.thisNode()
    m_nodeFn.setObject( m_object )
    print( "  --- {0} --- ".format( m_nodeFn.name()) )
    for i in range( m_nodeFn.attributeCount() ):
        m_atrr   = m_nodeFn.attribute(i)
        m_fnAttr = OpenMaya.MFnAttribute( m_atrr )
        print( m_fnAttr.name() )

Maya: Extra Attributes using Maya API classes

Dealt Maya API. Here I decided to post some example functions. The basic idea was using Maya API Python classes realize workflow with extra attributes at native Maya node. Suppose you want to make a script that stores some data in one native Maya node (in the script node, for example), and if user do not have your script, nothing terrible will happen, node modified by you will work without any troubles. Sorry for my English.

You should get something like this:


Maya: isMeshHasSkinCluster()

I want to share useful function created by me, I use it in my scripts.
You can modify it in such a way that it will return a pointer to skinCluster for example. I also wrote a some comments. Hope it will be useful for someone.