You need to recast faceNumber so it knows its an int. Right now faceNumber is a string since you tokenized out the data as strings.
# Uses current selected face faceNumber = int(faceObjList[1]) <----------------- space = om.MSpace.kWorld vector = om.MVector() fn = om.MFnMesh(mDagPath) fn.getPolygonNormal(faceNumber, vector, space) RyanT Technical Artist www.rtrowbridge.com/blog NaughtyDog Inc. On Mar 31, 1:39 pm, Tucker <[email protected]> wrote: > My problem is this, i have one variable driving two operations. The > user selects a face and from that selection i get the face number and > obj name. I've tokenised the variable to get the correct sections of > the DAG path for the individual obj name and face name. The code is > this... > > # Select Object > selected = om.MSelectionList() > om.MGlobal.getActiveSelectionList(selected) > selectedObj = [] > selected.getSelectionStrings(selectedObj) > > # Tokenize the Node selection. Now faceObjList[0] is the object and > faceObjList[1] > # is the face Number > reg = re.compile( "([^.]+)\.\w+\[(\d+)\]$" ) > faceObjList = reg.match( selectedObj[0] ).groups() > > I then need to use the obj and face number to drive two differnt api > operations. Which are these... > > # Uses current obj > object = faceObjList[0] > selectionList = om.MSelectionList() > selectionList.add(object) > mDagPath = om.MDagPath() > mObj = om.MObject() > selectionList.getDagPath(0, mDagPath, mObj) > > # Uses current selected face > faceNumber = faceObjList[1] > space = om.MSpace.kWorld > vector = om.MVector() > fn = om.MFnMesh(mDagPath) > fn.getPolygonNormal(faceNumber, vector, space) > > Where as the selected object operation seems to have no problem > accepting the faceObjList[0] variable, the face selection operation > does. Every time i run the code it comes up with the following > error ... > > # File "C:\engserv\rbuild\194\build\wrk\optim\runTime\Python\Lib > \site-packages\maya\OpenMaya.py", line 4368, in getPolygonNormal > # TypeError: in method 'MFnMesh_getPolygonNormal', argument 2 of type > 'int' # > > I'm not sure what the problem is though i suspect it has some thing to > do with me using the wrong container for the variable. If any one can > offer any help that would be fantastic. Compleatly at a loss now. --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
