# how to repeat section with offset

## Recommended Posts

i want to repeat two segments of the channle curve but with an offest. let say, a obect moves in tx 0.5 in frame 10, moves in tx 0.8 in frame 20. after i create these 3 keyframe, i want the object continue this movement in tx. ( that is move 0.5 in frame 30, 0.8 in frame 40...so on)

here is what i want to achieve.

##### Share on other sites

and the result shoud look like that(i paint it out only )

is it possible to do it ? i tried the repeat(0,20), but could not get the offset!!

plz help.

##### Share on other sites

To shift the repeated parts vertically to match the previous cycle, you can use the following expression:

`repeat(1,20)+(chf("./tx",19)-chf("./tx",1))*floor((\$F-1)/19)`

First I repeated only frames 1-20, since frame 0 is normally for special setups, like bind-pose. Then there is this complicated looking part after the repeat-statement. The two chf()-functions calculate the offset, by which the copies must be shifted to match the previous one. If you want some other channels repeated with offset, you will have to adjust the channel-name "tx". Also note, what the frame of the first chf-function is 19 (= 20-1), since the value at frame 20 will already be determined by the custom-expression. the floor(...)-statement will count the cycles. A general formulation of the expression would be:

```repeat(SF,EF)+(chf("./CN",EF-1)-chf("./CN",SF))*floor((\$F-SF)/(EF-SF))
SF:   start-frame
EF:   end-frame
CN:  channel-name```

Sometimes Houdini messes up the display, if you move the end end-key of the repeated range. Then you will see some strange peaks, due to some round-off errors in the evaluation of the expression. If you close the channel-editor and reopen it, Houdini will place new sample-positions and everything is fine again.

##### Share on other sites

thank you so much!!

##### Share on other sites

A small generalization to Frank's expression is to replace "./tx" to "./\$CH" since \$CH will evaluate to the current channel name.

In Houdini 6, the expression reduces to:

`cycle(1,20)`

##### Share on other sites

how 'bout the cycleCHOP, you can cycle and offset among other things...?, but after looking at the expression edward posted i must say, that's pretty efficient.

##### Share on other sites

wow...only "cycle(1,20)"!!

what a big improvement for houdini 6

thanks guys

## Create an account

Register a new account