Softimage SDK Programmer's Guide > Script Development > Python Scripting > Examples >

# Command Examples

## Looping Through an Array

The following example shows how to loop through an array.

    Application.GetPrim( "Null" )
    Application.SetMarking( "kine.local.pos,kine.global.pos" )
    Application.AddToMarking( "kine.local.ori" )
    markings = Application.GetMarking()
    for i in markings:
        Application.LogMessage( i )

## Getting the Output Arguments from Commands

The following example uses the GetKeyInfo command to demonstrate how to use the ISIVTCollection with Python. The GetKeyInfo command does not have a return value, but uses nine output arguments in this order: Parameter, LeftValue, RightValue, LeftTanParam, LeftTanValue, RightTanParam, RightTanValue, RightSegKind, and Constraints. These arguments are returned as an ISIVTCollection object.

    from win32com.client import constants as c
    Application.NewScene( Application.ActiveProject, 0 )
    root = Application.ActiveSceneRoot

    # Set up an fcurve on a null
    oObj = root.AddNull()
    aKeys = ( 1, -5.0, 25, 7.0, 50, 2.0 )
    oFCurve = oObj.posx.AddFCurve2( aKeys, c.siDefaultFCurve )

    # The GetKeyInfo command uses these output parameters (in order)
    # Parameter LeftValue RightValue LeftTanParam LeftTanValue RightTanParam
    # RightTanValue RightSegKind Constraints
    ivtInfo = Application.GetKeyInfo( oFCurve, 1 )
    Application.LogMessage( "# of items: " + str(ivtInfo.Count) )

    # You can loop through the info
    for entry in ivtInfo :
        Application.LogMessage( str(entry) )

    # You can get the info by index
    i = ivtInfo.Count-1
    while i >= 0 :
        Application.LogMessage( "Item" + str(i+1) + " = " + str(ivtInfo(i)) )
        i = i - 1

    # You can get the info by name
    Application.LogMessage( "Parameter: " + str(ivtInfo.Value("Parameter")) )
    Application.LogMessage( "LeftValue: " + str(ivtInfo.Value("LeftValue")) )
    Application.LogMessage( "RightValue: " + str(ivtInfo.Value("RightValue")) )
    Application.LogMessage( "LeftTanParam: " + str(ivtInfo.Value("LeftTanParam")) )
    Application.LogMessage( "LeftTanValue: " + str(ivtInfo.Value("LeftTanValue")) )
    Application.LogMessage( "RightTanParam: " + str(ivtInfo.Value("RightTanParam")) )
    Application.LogMessage( "RightTanValue: " + str(ivtInfo.Value("RightTanValue")) )
    Application.LogMessage( "RightSegKind: " + str(ivtInfo.Value("RightSegKind")) )
    Application.LogMessage( "Constraints: " + str(ivtInfo.Value("Constraints")) )