GeomiTRY

From DreamsteepWiki

Jump to: navigation, search

THIS TOOK ME 1.5 WEEKS TO FIGURE OUT

I FIGURED IT OUT LOOKING AT ROB THE BLOKES http://maya.robthebloke.org/MSelectionList2.html ( C++ CONVERTS NICELY TO PYTHON (DOES IT WORK THE OTHER WAY AROUND??) )




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" 
			itGeom = OpenMaya.MItGeometry( dagPath, component )
			while not itGeom.isDone() :
				point = OpenMaya.MPoint( itGeom.position( OpenMaya.MSpace.kWorld ) )
	 			#// write the index and the position
				#print itGeom.index()
				print (str(point.x) + ' '+str(point.y) + ' '+ str(point.z) )
				#// next bit of geometry please
			        itGeom.next();
			it.next()

Personal tools