how do i set the “keep unbaked keys” to off from code
preserveOutsideKeys is the flag you’re looking for. Defaults to True, setting it to False will get what you want.
how do i set the “keep unbaked keys” to off from code
time is the flag you’re looking for here.
If you need to get the values from the time slider, use cmds.playbackOptions. You’ll want the min/max flags.
So in the end you’d have something like this:
import maya.cmds as cmds
min_time = cmds.playbackOptions(q=True, min=True)
max_time = cmds.playbackOptions(q=True, max=True)
# You'll probably have more flags set depending on your other options.
cmds.bakeResults(preserveOutsideKeys=False, time=(min_time, max_time))
I already found it on the web, thanks mate, it’s exactly what i needed!
In the end i just query for the start = cmds.findKeyframe(sel, which=“first”) and end = cmds.findKeyframe(sel, which=“last”) and if start != end: cmds.bakeResults(…