Refresh

Introduced

v1.0

Categories

viewing

Description

Forces the viewports to update the position and appearance of the objects in view (ie., a redraw of the UI). For example, you could use this command to demo a script where you want the user to be able to see each change as it is applied by the script (eg., for translations, usually the display doesn't update until all transformations have been executed).

Note: This is different from the functionality of SceneRefresh, which removes any temporary values (ie., values that are inconsistent with the animation fcurve that was set for those parameters).

Tip: To redraw the UI without logging the Refresh command to history, use the Desktop.RedrawUI method instead.

Scripting Syntax

Refresh( [Time] );

Parameters

Parameter Type Description
Time Double Frame at which to refresh

Default Value: Current frame

Examples

VBScript Example

'
' This example demonstrates the effect of the Refresh command by creating a few objects and 
' then translating them all at once without refreshing and then again while refreshing.
'
NewScene , false
' Set up some variables and constants to start
Set oSmarmy = CreateObject( "XSI.Collection" )
iDisplacement = 0
Const MAX_ARMY = 19
' This is just a utility loop that makes it easier adding a lot of elements to the scene
For i = 0 To 19
        ' Make a new soldier and add it to the army
        Set oSoldier = ActiveSceneRoot.AddNull()
        oSmarmy.Add oSoldier
        ' Get the array of position values for the soldier
        aPos = Array( oSoldier.posx.Value, oSoldier.posy.Value, oSoldier.posz.Value )
        ' If we've already made half the army, position them in one direction
        If i >= (MAX_ARMY/2) Then
                oSoldier.posx.Value = aPos(0) + iDisplacement 
                oSoldier.posy.Value = aPos(1) + iDisplacement 
                oSoldier.posz.Value = aPos(2) + iDisplacement 
        Else
                oSoldier.posx.Value = aPos(0) - iDisplacement 
                oSoldier.posy.Value = aPos(1) - iDisplacement 
                oSoldier.posz.Value = aPos(2) - iDisplacement 
        End If
        ' When we're half done, we need to reset the displacement counter 
        If iDisplacement = CInt(MAX_ARMY/2) Then
                iDisplacement = 0.1
        Else
                iDisplacement = iDisplacement + 0.2
        End If
Next
' Now that our army is built, let's move them towards us a set at a time for a few steps.
' (The display looks like a bunch of crosses marching steadily forward.)
move3Steps oSmarmy, true
' This will mark the separation between when they are advancing with/without refreshing
For iMark = 0 To 59
        Application.LogMessage " ---------- the army is coming ---------- "
Next
' Do it again, this time without refreshing.
' (The display looks like a bunch of crosses jumping forward at once.)
move3Steps oSmarmy, false
sub move3Steps( in_collection, in_refresh_flag )
        ' Local settings
        iStep = 0.25
        Const STEP_LIMIT = 30
        ' First clear the selection (just in case we get unwanted members)
        Selection.Clear
        ' Then set the selection according to the collection members specified 
        Selection.SetAsText in_collection.GetAsText
        ' Now we can move everything at one (using a loop to make it easier)
        For j = 0 To STEP_LIMIT
                Translate , , , +iStep
                ' If the refresh flag is set, then refresh the scene
                If in_refresh_flag Then
                        Refresh
                End If
        Next
end sub

See Also

Desktop.RedrawUI SceneRefresh DelayedRefresh