Mixing OpenMaya with cmds or pymel?

Just wondering if there are any major disadvantages to mixing in bits of maya.cmds or pymel with a scriptedCommand i am building with the maya python api.

what im working on requires both a face selection and a border selection, and in the API there really is no easy way to do that kinda selection conversion, so i was thinking i just save out a selectionList, call some code from the cmds modual, than save a new selectionList

So I personaly don’t think there’s any big disadvantages. If your worried about speed you should checkout this post.

Now you should pick either Maya.cmds or PyMel.core you will probably never need to use both considering they have the same commands.
So the cool thing about PyMel is that it works very well with OpenMaya. You can quickly get the objects dag and this will allow PyMel and
OpenMaya to work together. Here’s a little example…


import maya.OpenMaya as om
import pymel.core as pymel

def name( node ):
	"""
	*Returns:*
		* ``node_name`` Returns DAG's full path name.
	"""
	nodeFn = om.MFnDagNode( node )
	node_name = nodeFn.fullPathName()

	return node_name
		

loc = pymel.spaceLocator()	
loc_node = name(loc.__apimdagpath__())

Here’s another example where I mix Maya.cmds with maya.OpenMaya
https://github.com/nicholas-silveira/art_pipeline/blob/master/maya/packages/oop_maya/core/maya_callback.py

Hope this helps.
-Nick

1 Like