Evgeniy Zaitsev Technical Artist

12Jun/16Off

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

Download : vtxNormalsToSoftHardEdges.zip
Usage:

 
import vtxNormalsToSoftHardEdges; vtxNormalsToSoftHardEdges.convertNormals();


11Jan/16Off

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() )
17Nov/15Off

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() )
	m_iterator.next()  

16Nov/15Off

Get all extra attributes Maya Python API

Select the node and run:

 
m_list = getAllExtraAttributes()
print( m_list )

16Nov/15Off

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() )
    m_iterator.next()
28Jul/10Off

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:

27Jul/10Off

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.