Selection

From DreamsteepWiki

Jump to: navigation, search

GET SELECTED taken from http://maya.robthebloke.org/MSelectionList2.html converted line by line from c++ code


class scriptedCommand(OpenMayaMPx.MPxCommand):
	def __init__(self):
		OpenMayaMPx.MPxCommand.__init__(self)
     		fPolygonSets = OpenMaya.MObjectArray()
     		fPolygonComponents = OpenMaya.MObjectArray()
     		fShape = OpenMaya.MFnMesh()

	def doIt(self,argList):
		selList = OpenMaya.MSelectionList() 
		#// Get the list of selected items 
		OpenMaya.MGlobal.getActiveSelectionList( selList )
		#// we will use an iterator this time to walk over the selection list.
		it = OpenMaya.MItSelectionList( selList )
		while not it.isDone() :
			dagPath = OpenMaya.MDagPath()	
			component  = OpenMaya.MObject()
			it.getDagPath( dagPath, component )

			#// use a function set to print the name of the object
			fn = OpenMaya.MFnDependencyNode( dagPath.node() )
			print "OBJECT: " + fn.name() + "\n" 

			it.next()

Personal tools