On 13/01/2017 at 16:18, xxxxxxxx wrote:
Holy mackerel, that's an old post @gr4ph0s linked. Note that there's a bug in MoveSelectedKeys() if
you pass a value for timeln not in the range [1..4].
def MoveSelectedKeys(op,offset,timeln = 1) : # offset in frames
import c4d
if (not op) or (not offset) : return False
if timeln == 1: timeln = c4d.NBIT_TL1_SELECT
elif timeln == 2: timeln = c4d.NBIT_TL2_SELECT
elif timeln == 3: timeln = c4d.NBIT_TL3_SELECT
elif timeln == 4: timeln = c4d.NBIT_TL4_SELECT
else:
import math
timeln = math.fmod(timeln,4)
MoveSelectedKeys(op,offset,timeln)
**return # <<< missing**
doc = op.GetDocument()
track = op.GetFirstCTrack()
if not track: return False
fps = float(doc.GetFps())
while track:
curve = track.GetCurve()
cnt = curve.GetKeyCount()
for i in xrange(cnt) :
key = curve.GetKey(i)
if key.GetNBit(int(timeln)) == True:
tme = key.GetTime()
key.SetTime(curve,c4d.BaseTime(offset/fps+tme.Get()))
track = track.GetNext()
c4d.EventAdd(c4d.MSG_UPDATE)
return True