hi all,
i'm doing a basic mesh info script following loosely the David Gould c++
script(which i have no idea about). I want to write out a basic text
file with python for use later. i just want the numbers of polys and
verts and then the poly-vert associations.
this is pritty much my first api script and really just for kicks and to
try learn some python Api. of cource i have hit the wall with trying to
iterate over the polycount of an object. as i know you cant do it in a
python method. i was trying to assign a variable to a
OpenMaya.MIntArray() and then iterate over that but i'm either doing it
wrong or its just not possible. could anyone let me know what i'm doing
wrong or what direction i should take
my script so far is.
i just select the shape node of the mesh object
***********************
#import sys
import maya.OpenMaya as OpenMaya
#import maya.OpenMayaMPx as OpenMayaMPx
def meshInfo(shapeNode):
#print "hello"
mObj = OpenMaya.MObject()
selectionList = OpenMaya.MSelectionList()#get list of objects
#print selectionList
dagPath = OpenMaya.MDagPath()
OpenMaya.MGlobal.getActiveSelectionList(selectionList)#get the list
of selected info
#selectionList.add( shapeNode )
selectionList.getDependNode( 0, mObj )#get the depandants shape
print mObj.apiType()
if( mObj.apiType() == OpenMaya.MFn.kMesh ):
print 'its a mesh'
newDagPath = OpenMaya.MDagPath()
dagPath.getAPathTo( mObj, newDagPath )
try:
meshFn = OpenMaya.MFnMesh( mObj )
print 'yep'
except:
sys.stderr.write("!!! ERROR :: can not create meshFn")
try:
polyIter = OpenMaya.MItMeshPolygon( newDagPath )
print 'yep2'
except:
sys.stderr.write("!!! ERROR :: can not create polyIter")
try:
polyVertIter = OpenMaya.MItMeshFaceVertex( newDagPath )
#iterate over the face verts
print 'yep3'
except:
sys.stderr.write("!!! ERROR :: can not create polyVertIter")
numPolys = OpenMaya.MIntArray()
print 'numpolys'
meshFn.numPolygons(numPolys)
print polyIter.count()
for i in numPolys: ##just trying to iterate over some value and
trying not to revert to mel or mayapy
print i,
#get poly number and vertex points
#eventually print to file
#v1:(1.0, 0 ,1)
#v2:(etc)
#p1:(v1,v4,v19) etc
else:
print 'not kMesh'
any help would be great
john
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---