[Maya] setKeyframe -time flag issue

I’m having a strange behaviour with the setKeyframe command in Maya, when I give it a list of frames it sets a key at those times but it uses the value on the last one to set the other values, all I want to do is key the attribute at whatever value they have at that given time.

Example:

cmds.setKeyframe(“character:leg_ctrl.parentSpace”, time = [30, 40, 50])

It will key the “parentSpace” attribute at those frames, but will take whatever value it has at frame 50 and apply it in frames 30 and 40.

I’m not sure if this is a bug or I’m not using this command properly.

I’m not seeing that behavior in my quick and dirty test. Though I was keying translateX, so maybe the type of attribute is the problem?

I’ve had that issue before. To fix it, use the “insert” flag:

cmds.setKeyframe("character:leg_ctrl.parentSpace", time=[30, 40, 50], insert=True)

Sweetthanks! I didn’t see that flag at all, I ended up making a function to fix it myself. Now I know :slight_smile:

I also had the issue with translateX, perhaps it’s another maya version?
RFlannery gave me the solution and it worked, I was missing the “insert” flag.

cmds.setKeyframe(“character:leg_ctrl.parentSpace”, time=[30, 40, 50], insert=True)