Create animation curve on specific animation layer c++

Create animation curve on specific animation layer c++

oliv.dxyz
Participant Participant
862 Views
3 Replies
Message 1 of 4

Create animation curve on specific animation layer c++

oliv.dxyz
Participant
Participant

Hi everyone,

 

I am working on a C++ plugin that creates animation curves for a list of attributes. It works well when there is only the BaseAnimation anim layer, but when there are multiple animation layers for my attributes, the plugin fails to create the curves. I am able to get the plug I am looking for, then :

 

When there are no keys on the attribute I am using MFnAnimCurve::create(const MPlug &plug, AnimCurveType animCurveType, MDGModifier *modifier=NULL, MStatus *ReturnStatus=NULL) and it fails with error "(kInvalidParameter): Dependency graph plug already has connection".


And when there are keys, I am trying to get the existing curve with MFnAnimCurve(const MPlug &plug, MStatus *ReturnStatus=NULL) and it fails with "(kNotImplemented): Unexpected Internal Failure".

 

I don't think I really understand the relationship between attributes and animation layers, but I did not see any function specifying an animation layer in the C++ API. However, I see a lot of people working with Python/MEL asking how to specify an animation layer when adding keyframes and it seems possible for them. The command setKeyFrame can specify the animation layer name, but in C++ MFnAnimCurve::addKeys cannot...

I also looked at the Maya devkit example "atomImportExport" but they don't seem to create anim curves from scratch and this is really what I need to do.

 

So my question is : is there a way to specify the animation layer with C++ to create an animation curve and set keys on this layer only ?

 

Thanks,

0 Likes
863 Views
3 Replies
Replies (3)
Message 2 of 4

oliv.dxyz
Participant
Participant

UP
I still haven't found a way, if anyone has a solution...

0 Likes
Message 3 of 4

oliv.dxyz
Participant
Participant

UP
I still haven't found a way, if anyone has a solution...

0 Likes
Message 4 of 4

peerke88
Contributor
Contributor

in the same boat, it seems that the connections that are already attached come from the animation layer nodes.
so in order to create the correct curve, the connections of animationlayer nodes and blend nodes needs to be traversed
if we have baselayer , animlayer1, animlayer2 the node connection looks like:
baseCurve     -    animlayer 1 blend   -  animlayer2 blend - our node
animcurve 1 ┘             animcurve 2 ┘

so in order to work with the correct layer we need to map which blendnodes work with which layer
and if we work with the base layer we need to traverse the network as much as possible to find the original curve in the input1 of the first blend node

would be great if someone else has better insight on managing this

0 Likes