Softimage SDK Programmer's Guide > Working with the SDK > Animation > Playback Controls >

# Running Commands During Playback at Each Frame Change

You may need to run a quick command at every frame change during playback, such as logging some scene information based on the current animation. There is a parameter on the PlayControl property set which can hold a simple VBScript snippet that will run whenever the frame changes. This is the OnFrameChangeCommand parameter (see VBScript Example: Logging an Object's Position at Each Frame Change).

Important

This parameter is only triggered during playback. If you are looking for an event that will be triggered by a frame change during rendering, you must implement an event handler for the OnBeginFrame or OnEndFrame event. For more information, see A Note About Event Handlers for Rendering.

## VBScript Example: Logging an Object's Position at Each Frame Change

This example logs the null's position in 3 separate calls to Application.LogMessage.

Tip

VBScript is the only supported language for this command. Note that since VBScript marks the end of lines with a return character, if you want to run more than a one-line command you must separate each line of code with vbCrLf (VBScript enum for the return character).

    dim cmd2run
    cmd2run = "Application.LogMessage GetValue(" & Chr(34) & "null.kine.local.posx" & Chr(34) & ")" & vbCrLf _
    & "Application.LogMessage GetValue(" & Chr(34) & "null.kine.local.posy" & Chr(34) & ")" & vbCrLf _
    & "Application.LogMessage GetValue(" & Chr(34) & "null.kine.local.posz" & Chr(34) & ")"
    SetValue "PlayControl.OnFrameChangeCommand", cmd2run

## A Note About Event Handlers forRendering

If you need to run something at every frame update during rendering, you can use one of these events (for more information about how to implement these events, see Custom Events):

- OnBeginFrame—triggered before a frame gets rendered. These events are registered with the siOnBeginFrame enum.

- OnEndFrame—triggered after a frame gets rendered. These events are registered with the siOnEndFrame enum.

Tip

If you want a frame change during rendering to trigger an event, you must use either the siOnBeginFrame or siOnEndFrame event handlers. The OnFrameChangeCommand parameter is only triggered during playback.