## Clip

Object Hierarchy | Related C++ Class: Clip

### Inheritance

###

SIObject

ProjectItem

Clip

### Introduced

v1.5

### Description

Clips are instances of animation and shape actions (ActionSource), audio and image sources (Source) and compound clips (ClipContainer). You can check to see the clip type (such as an audio clip) using the SIObject.Type property which returns one of the values contained in the siClipType enum.
This object also provides access to clip features such as its timing (TimeControl), any links to other clips (ClipRelation), and any applied effects (ClipEffect). In addition, you can get the underlying source on which this clip is instantiated (the Source object via Clip.Source) or the elements of that source (using either the MappedItem object via Clip.MappedItems or the AnimationSourceItem object via ActionSource.SourceItems).
Important: While the Clip object represents compound, audio, and image clips, not all Clip methods and properties are available for these types. For example, the Clip.MappedItems property will fail and report that it is not implemented for these clip types (ie., returns E_NOTIMPL).
Tip: There is no function in the object model to create clips from sources, but you can use the AddClip command, which returns this object. To access existing Clip objects, you can get the ClipCollection on the Mixer via the ClipContainer.Clips property.

### Methods

AddCustomOp | AddICEAttribute | AddProperty | AddProperty2
AddScriptedOp | AddScriptedOpFromFile | AnimatedParameters2 | BelongsTo
EvaluateAt | GetICEAttributeFromName | IsA | IsAnimated2
IsClassOf | IsEqualTo | IsKindOf | IsLocked
IsSelected | LockOwners | RemoveICEAttribute | SetAsSelected
SetCapabilityFlag | SetLock | TaggedParameters | UnSetLock

### Properties

Application | BranchFlag | Capabilities | Categories
Effect | EvaluationID | Families | FullName
Help | HierarchicalEvaluationID | ICEAttributes | LockLevel
LockMasters | LockType | MappedItems | Model
Name | NestedObjects | ObjectID | Origin
OriginPath | Owners | PPGLayout | Parameters
Parent | Parent3DObject | Properties | Relations
Selected | Source | TimeControl | Type

### Examples

#### 1. Python Example

    #

    # This example demonstrates how to create a Clip containing the static

    # values of the local position of an object.

    #

    oRoot = Application.ActiveSceneRoot

    oCube = oRoot.AddGeometry( "Cube", "MeshSurface" )

    # Creating the first animation source

    sParams = "cube.kine.local.posx,cube.kine.local.posy,cube.kine.local.posz"

    oSource = Application.StoreAction( oRoot, sParams, 1, "StoredStaticPose", 1, 1, 5, 0, 0)

    # Creating the first clip

    oClip = Application.AddClip( oRoot, oSource )

    Application.LogMessage( "First created clip " + oClip.FullName )

    # Creating the second animation source

    oCube.Parameters("posx").Value = 3.0

    oSource2 = Application.StoreAction( oRoot, sParams, 1, "StoredStaticPose", 1, 7, 9, 0, 0 )

    # Creating the second clip

    oClip2 = Application.AddClip(oRoot, oSource2)

    Application.LogMessage("Second created clip " + oClip2.FullName)

    # Expected results:

    #INFO : First created clip Mixer.Mixer_Anim_Track.StoredStaticPose_Clip

    #INFO : Second created clip Mixer.Mixer_Anim_Track1.StoredStaticPose1_Clip

#### 2. JScript Example

    /*

    This example demonstrates working with action and audio sources and clips

    */

    NewScene( null, false );

    // Do it on a nested model

    var mdl = ActiveSceneRoot.AddModel();

    mdl.Name = "TestModel";

    // ----------------------

    // Create an fcurve source and instantiate a clip in the mixer

    var obj = mdl.AddNull();

    // Set FCurves on the null's scaling

    var keys = new Array( 5, 1.2,  20, 1.7,  45, 2.0,  90, 2.5 );	// X

    obj.sclx.AddFCurve2( keys );

    var keyfactor = Math.random() * 10;					// Y

    var posfactor = Math.random();

    for ( var i=0; i<keys.length; i=i+2 ) {

    	keys[i] = keys[i] + keyfactor;

    	keys[i+1] = keys[i+1] * posfactor;

    }

    obj.scly.AddFCurve2( keys );

    var keyfactor = Math.random() * 10;					// Z

    var posfactor = Math.random();

    for ( var i=0; i<keys.length; i=i+2 ) {

    	keys[i] = keys[i] - keyfactor;

    	keys[i+1] = keys[i+1] * posfactor;

    }

    obj.sclz.AddFCurve2( keys );

    // Get list of parameters to mark

    var params = obj.sclx.FullName + ",";

    params += obj.scly.FullName + ",";

    params += obj.sclz.FullName;

    // Make the FCurves into an Action

    var src = StoreAction( mdl, params, 2, "StoredAnimFCrvAction" );

    AddClip( mdl, src );

    // ----------------------

    // Add an audio clip to the mixer

    var mix;

    if ( mdl.HasMixer() ) {

    	mix = mdl.Mixer;

    } else {

    	mix = mdl.AddMixer();

    }

    var aud_track = AddTrack( mdl, mix, 2 );

    var aud_src_path = XSIUtils.BuildPath( Application.InstallationPath( siFactoryPath ), "Data", "XSI_SAMPLES", "Audio", "Torefaction.wav" );

    var aud_src = ImportAudio( mdl, aud_src_path );

    AddAudioClip( mdl, aud_src );

    // ----------------------

    // Find the clips under the mixer

    var cliplist = mdl.Mixer.Clips;

    for ( var c=0; c<cliplist.Count; c++ ) {

    	var clip = cliplist(c);

    	LogMessage( "----------------------" );

    	LogMessage( "Found a clip of type " + clip.Type + " under " + mdl.Mixer );

    	// Get the underlying source items associated with this clip, but make sure

    	// we skip the audio files

    	if ( clip.Type == siClipAnimationType ) {

    		LogMessage( "Found " + clip.MappedItems.Count + " mapped items on " + clip );

    		for ( var m=0; m<clip.MappedItems.Count; m++ ) {

    			var itm = clip.MappedItems(m);

    			LogMessage( "Found this mapped item: " + itm.Source2 + " (a " + ClassName(itm.Source2) + ")" );

    		}

    	}

    }

    // Expected results:

    //INFO : ----------------------

    //INFO : Found a clip of type mixeranimclip under TestModel.Mixer

    //INFO : Found 3 mapped items on TestModel.Mixer.Mixer_Anim_Track.StoredAnimFCrvAction_Clip

    //INFO : Found this mapped item: FCurve (a FCurve)

    //INFO : Found this mapped item: FCurve (a FCurve)

    //INFO : Found this mapped item: FCurve (a FCurve)

    //INFO : ----------------------

    //INFO : Found a clip of type mixeraudioclip under TestModel.Mixer

### See Also

AddClip ClipContainer.Clips Track.Clips CopyClipToTrack AddAudioClip ImportAudioAndAddClip ApplyShapeKey SaveShapeKey