MFnAnimCurve building

119 views
Skip to first unread message

Mark Jackson

unread,
May 16, 2017, 2:15:45 PM5/16/17
to python_inside_maya

I'm wondering if anybody could shed a light on issues I'm having with setting up animCurves through the API, or more specifically the key Tangents.

Basically I've moving our animFormat into API and have pretty much got everything running but one of the regression tests is failing. It seems like the order in which you set the MFnAnimCurve tangent vars affects the resulting curve and how the tangents are built

I'm running the following for key in keys on an MFnAnimCurve to try and rebuild the tangents as per the original ....


crvFnc.setTangentsLocked(kindex, lockedTangents) 
                                        
if weightedTans:
    # only settable if the curve has weighted tangents
    crvFnc.setWeight(kindex, iw, 1)
    crvFnc.setWeight(kindex, ow, 0)
    crvFnc.setWeightsLocked(kindex, wl) 
   
crvFnc.setAngle(kindex, OpenMaya.MAngle(math.radians(inAngle)), 1) 
crvFnc.setAngle(kindex, OpenMaya.MAngle(math.radians(outAngle)), 0)

crvFnc.setInTangentType(kindex, AC_TANGENT_TYPES[inTangentType])
crvFnc.setOutTangentType(kindex, AC_TANGENT_TYPES[outTangentType])


.... but it seems like the order I set this data changes the results and I'll be damned if I can get a sequence that loads everything back as intended, even though the saved data is all correct

Can anybody shed any light on this?

cheers

Mark


-------------------------------------
Mark Jackson
CEO / Technical Director
red9consultancy.com

Alok Gandhi

unread,
May 16, 2017, 8:04:45 PM5/16/17
to python_in...@googlegroups.com
Can you be more specific with the type of change? Is it the slope of the tangents, their length or something else that changes?

I think setAngle() method may be the cause of this. 

Note that if this method is called on a locked tangent (which they are by default), the corresponding out- or in-tangent will be modified as well (i.e., they will both be set to fixed). To prevent this from occurring, you must first unlock the tangent, make your modifications and then restore the lock setting for the tangent afterwards.

I think in your case if the order of setAngle would change the slope of the tangents if you do this operation without unlocking the tangent. Try setting the angles after unlocking the tangents and then lock them again.  

--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAGQH2FG0gm3oUP5uJTTg4Pu1W4E_Ro2bM2K2%2BoL6vZUr5KdQng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--

Mark Jackson

unread,
May 17, 2017, 4:22:25 AM5/17/17
to python_inside_maya
thanks Alok,

I found the issue late last night, turns out on one of the test scenes the tangents had been broken, manually modified, then set locked, so the setAngle was indeed getting the data wrong. As you said if the tangents are unlocked, then the setAngle, then the tangents set locked as required things start to behave.

cheers

Mark


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.



--

--
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 python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMStr%3DSsLoD1DoJ8zYfwRQ_EiyAofw3MUD%3DO6V2fAbiAKw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages