pax...@iconcreativestudio.com
unread,Aug 21, 2018, 5:12:00 PM8/21/18Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Python Programming for Autodesk Maya
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)