Hey Guys, I am a bit stuck trying to create driven (unitless) animCurves with 
OpenMaya

I am in maya 2017, using OpenMaya api 2.0

I am trying to use MFnAnimCurve to create multiple keyframes at the same time. 
this seems to work when using timed curve types (using MTimeArray as first 
argument) but it fails when using unitless curves and a MDoubleArray for the 
first argument.. Am I missing something? should i be using a different type for 
the first argument?



import maya.api.OpenMaya as om
import maya.api.OpenMayaAnim as oma

graph_modifier = om.MDGModifier()

m_object = om.MFnDependencyNode().create('transform', 'locator1')
node = om.MFnDependencyNode(m_object)

m_plug = node.findPlug(node.attribute('translateX'), True)
out_plug = node.findPlug(node.attribute('translateY'), True)


mfn_anim_curve = oma.MFnAnimCurve()
curve_type = mfn_anim_curve.unitlessAnimCurveTypeForPlug(m_plug)
#curve_type = mfn_anim_curve.timedAnimCurveTypeForPlug(m_plug)


anim_curve_m_object = oma.MFnAnimCurve().create(m_plug, 
animCurveType=curve_type)
anim_curve = oma.MFnAnimCurve(anim_curve_m_object)

in_plug = anim_curve.findPlug(anim_curve.attribute('input'), True)

graph_modifier.connect(out_plug, in_plug)
graph_modifier.doIt()


in_values = om.MDoubleArray()
out_values = om.MDoubleArray()
for x in range(5):
    in_values.append(float(x))
for x in range(5):
    out_values.append(float(x))

print in_values, out_values

anim_curve.addKey(1.0, 1.0)
anim_curve.addKey(2.0, 2.0)

#This Fails
anim_curve.addKeys(in_values, out_values)

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/4641c1ee-0ddd-445e-b22e-1719447d0336%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to