Hoping i am just doing somthing wrong,
but:
import maya.OpenMayaAnim as omAn
## instance the MFnAnimCurve() function set
crvFnc = omAn.MFnAnimCurve()
## make a curve
crv = crvFnc.create(mplug,crvtype)
## ok it has all worked so far.........
## but then:
## (om.MTime().kFilm.... no variation makes a difference .. even just
leaving the mtime type out of it)
time = om.MTime(1 , om.MTime.kFilm)
crv.addKey(time , 2.5 , MFnAnimCurve.kTangentStep ,
MFnAnimCurve.kTangentStep)
### errors:
# Error: addKey
# Traceback (most recent call last):
# File "<maya console>", line 4, in <module>
# File "C:\Users\mtherrell\Documents\maya\milldev\millToolMaya.py",
line 91, in createAnimCurveOnLayer
#
crv.addKey(time,tvp[1],MFnAnimCurve.kTangentStep ,MFnAnimCurve.kTangentStep)
# File "D:\buildforge\Maya_2011_Win64_Build\build\wrk\optim\runTime
\Python\Lib\site-packages\maya\OpenMaya.py", line 1466, in <lambda>
# File "D:\buildforge\Maya_2011_Win64_Build\build\wrk\optim\runTime
\Python\Lib\site-packages\maya\OpenMaya.py", line 34, in _swig_getattr
# AttributeError: addKey #
the same "_swig_getattr", "AttributeError" for any of the addKey(s) or
addKeyframe functions of MFnAnimcurve in the python API.
It seems like this mysterious location of OpenMaya.py (which does not
actually exist on my computer) is some internal way of refering to the
Python/Lib/site-Packages/OpenMaya.pyc file which is the only file
close to that name that does exist, and must be where maya is getting
it python api functionality from. (i guess we are not allowed by
Autodesk to see the original OpenMaya.py to figure out whats wrong.)
This is the error, however, that one gets when one refers to a
function or attribute of a function that does not exist. as though
within the MfnAnimCurve function set for python, they forgot to add
the 'addKey' and 'addKeyFrame(s)' functions.
But the functions are members.. see below
i do not want to use mel setKeyFrame or keyframe. too slow. takes many
seconds to build keyframes for all the attrs i entend to animate.
this works fine in the normal c++ API, but i want to have this
functionality in a python script (for well known and well discussed
reasons.)
.. this should be possible.
i want to use the python API to create an AnimCurve node with all its
keys and values in one fell swoop in order to make what i am doing
fast and in python, and in a script.
any ideas where this is going wrong?
to see what member functions exist:
one can list all the member functions of a class in python.
i did this to the MFnAnimCurve function set.
in the python script editor i did this:
>>>>
import maya.OpenMayaAnim
import inspect
crvFnc = OpenMayaAnim.MFnAnimCurve()
funclist = inspect.getmembers(crvFnc)
for func in funclist:
print func
<<<<
they deffinately did not forget to add the methods related to
addKey(s):
because they are there in the list of functions including all
inhereted.
so either they are not working properly, i am not sending arguments to
them in the right way, or they are not intended by maya to work in
python yet they are not documented as "No Script Support" in the
current API docs for 2011.
--
http://groups.google.com/group/python_inside_maya