Hello, ok i just need to figure out why this code isn’t working properly.
I use the ‘getPoints()’ method and store all the verts of a certain piece of geo as ‘MPoints’
i then find the difference between two meshes (in the findDiff function) and store them in an MFloatPointArray()
then finally take this result and add it to the original mesh (in the addDiff function) - here is where the problem comes. Its obviously one of the items is the wrong type or something and it returns this error:
in method ‘MFloatPoint___add__’, argument 2 of type ‘MFloatVector const &’ #
here is the code:
import maya.OpenMaya as om
def getPoints(geo):
sel = om.MSelectionList()
dag = om.MDagPath()
sel.add(geo)
sel.getDagPath(0,dag)
mesh = om.MFnMesh(dag)
vts=om.MPointArray()
mesh.getPoints(vts, om.MSpace.kObject)
return mesh,vts
def findDiff(scan1_verts, scan2_verts):
diff_list=om.MFloatPointArray()
for i in xrange(scan1_verts.length()):
p1 = scan1_verts[i]
p2 = scan2_verts[i]
diff_list.append(om.MFloatPoint(p1-(p1-p2)))
return diff_list
def addDiff(diff_list, target_mesh_verts):
final_list=om.MFloatPointArray()
for i in xrange(target_mesh_verts.length()):
p1 = diff_list[i]
p2 = target_mesh_verts[i]
final_list.append(om.MFloatPoint(p1+p2))
return final_list
#store the vert positions for each mesh
mFnMeshTarget, target_mesh_verts = getPoints("target")
mFnMesh, scan1_verts = getPoints("neutralShape")
mFnMesh, scan2_verts = getPoints("expressionShape")
#find the difference between the verts from the expression scan and neutral scan
diff_list = findDiff(scan1_verts,scan2_verts)
finalPos = addDiff(diff_list, target_mesh_verts)
Can anyone show me how to make the p1 and p2 elements in the ‘addDiff’ function addable.
thanks,
Sam
