Ok, so we're trying to use a vector data variable within our tool development using Maya API.
import maya.OpenMaya as om
myVec= [ 0.0, 1.0, 2.0 ]
VecA= om.MVector( myVec )
# Error: Wrong number of arguments for overloaded function 'new_MVector'.
This would work if we directly parse arguments into the MVector class with:
VecA= om.MVector ( 0.0, 1.0, 2.0 )
This is because the Maya API is written in C++. The python component translated into the API is being handled by SWIG within Maya. So for this Maya 2011 version of SWIG, it is unable to directly translate pythons ease of coding directly into the C++ language. So to overcome this, we can override om.MVector class with a new method as shown below:
class MVector( om.MVector ):
def __init__(self, *args):
if( issubclass, args, list ) and len(args[0])== 3:
om.MVector.__init__(self, args[0][0], args[0][1], args[0][2])
else:
om.MVector.__init__(self, args)
We can then directly plug in our code.
myVec= [0.0, 1.0, 2.0]
VecA= om.MVector( myVec )