Hi Dan,
Thank you so much for your reply! This works almost as needed. The only problem is that it seems to only loop correctly when the layer starts from time 0, when moving the layer in time the loop gets offset, since the original keyframes are being moved with it.
I tried doing the following:
valueAtTime(finalTime%(loopDuration+key(1).time))
This works correctly for the first loop but then of course has a pause of that key(1).time, until the next loop happens again. I cannot seem to figure out how to cancel this ‘pause’so that the loop starts right after ignoring the key(1).time.