CompItem object

The CompItem object represents a composition, and allows you to manipulate and get information about it. Access the objects by position index number in a project’s item collection.

  • CompItem is a subclass of AVItem, which is a subclass of Item. All methods and attributes of AVItem and Item, in addition to those listed below, are available when working with CompItem. See AVItem and “Item object”.

Syntax:

app.project.item(index)
app.project.items[index]

Example

Given that the first item in the project is a CompItem, the following code displays two alerts. The first shows the number of layers in the CompItem, and the second shows the name of the last layer in the CompItem.

var firstComp = app.project.item(1); alert("number of layers is " + firstComp.numLayers); alert("name of last layer is " + firstComp.layer(firstComp.numLayers).name);

Attribute List

Attribute Description
frameDuration The duration of a single frame.
dropFrame When true, indicates that the composition uses drop-frame timecode.
workAreaStart The work area start time.
workAreaDuration The work area duration.
numLayers The number of layers in the composition.
hideShyLayers When true, shy layers are visible in the Timeline panel.
motionBlur When true, motion blur is enabled for this composition.
draft3d When true, Draft 3D mode is enabled for the Composition panel.
frameBlending When true, time filtering is enabled for this composition.
preserveNestedFrameRate When true, the frame rate of nested compositions is preserved.
preserveNestedResolution When true, the resolution of nested compositions is preserved.
bgColor The background color of the composition.
activeCamera The current active camera layer.
displayStartTime Changes the display of the start time in the Timeline panel.
resolutionFactor The factor by which the x and y resolution of the Composition panel is downsampled.
shutterAngle The camera shutter angle.
shutterPhase The camera shutter phase.
motionBlurSamplesPerFrame The minimum number of motion blur samples per frame for Classic 3D layers, shape layers and certain effects.
motionBlurAdaptiveSampleLimit The maximum number of motion blur samples of 2D layer motion.
layers The layers of the composition.
selectedLayers The selected layers of the composition.
selectedProperties The selected properties of the composition.
renderer The rendering plug-in module to be used to render this composition.
renderers The set of available rendering plug-in modules.

Method List

Method Description
duplicate() Creates and returns a duplicate of this composition.
layer() Gets a layer from this composition.
openInViewer() Opens the composition in a Composition panel.

Detailed Description

activeCamera attribute

Syntax: app.project.item(index).activeCamera

Description: The active camera, which is the front-most camera layer that is enabled. The value is null if the composition contains no enabled camera layers.

Type: CameraLayer object; read-only.

bgColor attribute

Syntax: app.project.item(index).bgColor

Description: The background color of the composition. The three array values specify the red, green, and blue components of the color.

Type: An array containing three floating-point values, [R, G, B], in the range [0.0..1.0]; read/write.

displayStartTime attribute

app.project.item(index).displayStartTime

Description: The time set as the beginning of the composition, in seconds. This is the equivalent of the Start Timecode or Start Frame setting in the Composition Settings dialog box.

Type: Floating-point value in the range [0.0...86339.0] (1 second less than 25 hours); read/write.

draft3d attribute

Syntax: app.project.item(index).draft3d

Description: When true, Draft 3D mode is enabled for the Composition panel. This corresponds to the value of the Draft 3D button in the Composition panel.

Type: Boolean; read/write.

dropFrame attribute

Syntax: app.project.item(index).dropFrame

Description: When true, indicates that the composition uses drop-frame timecode. When false, indicates non-drop-frame timecode. This corresponds to the setting in the Composition Settings dialog box.

Type: Boolean; read/write.

duplicate() method

Syntax: app.project.item(index).duplicate()

Description: Creates and returns a duplicate of this composition, which contains the same layers as the original.

Parameters: None.

Returns: CompItem object.

frameBlending attribute

Syntax: app.project.item(index).frameBlending

Description: When true, frame blending is enabled for this Composition. Corresponds to the value of the Frame Blending button in the Composition panel.

Type: Boolean; if true, frame blending is enabled; read/write.

frameDuration attribute

Syntax: app.project.item(index).frameDuration

Description: The duration of a frame, in seconds. This is the inverse of the frameRate value (frames-per-second).

Type: Floating-point; read/write.

hideShyLayers attribute

Syntax: app.project.item(index).hideShyLayers

Description: When true, only layers with shy set to false are shown in the Timeline panel. When false, all layers are visible, including those whose shy value is true. Corresponds to the value of the Hide All Shy Layers button in the Composition panel.

Type: Boolean; read/write.

layer() method

Syntax:

app.project.item(index).layer(index)
app.project.item(index).layer(otherLayer, relIndex)
app.project.item(index).layer(name)

Description: Returns a Layer object, which can be specified by name, an index position in this layer, or an index position relative to another layer.

Parameters: * index The index number of the desired layer in this composition. An integer in the range [1...num-Layers], where numLayers is the number of layers in the composition.

or

  • otherLayer A Layer object in this composition. The relIndex value is added to the index value of this layer to find the position of the desired layer.
  • relIndex The position of the desired layer, relative to otherLayer. An integer in the range [1–other-Layer.index...numLayers–otherLayer.index], where numLayers is the number of layers in the composition.

    This value is added to the otherLayer value to derive the absolute index of the layer to return.

or

  • name The string containing the name of the desired layer.

Returns: Layer object.

layers attribute

Syntax: app.project.item(index).layers

Description: A LayerCollection object that contains all the Layer objects for layers in this composition. See “LayerCollection object” on page 95.

Type: LayerCollection object; read-only.

motionBlur attribute

Syntax: app.project.item(index).motionBlur

Description: When true, motion blur is enabled for the composition. Corresponds to the value of the Motion Blur button in the Composition panel.

Type: Boolean; read/write.

motionBlurAdaptiveSampleLimit attribute

Syntax: app.project.item(index).motionBlurAdaptiveSampleLimit

Description: The maximum number of motion blur samples of 2D layer motion. This corresponds to the Adaptive Sample Limit setting in the Advanced tab of the Composition Settings dialog box.

Type: Integer (between 16 and 256); read/write.

motionBlurSamplesPerFrame attribute

Syntax: app.project.item(index).motionBlurSamplesPerFrame

Description: The minimum number of motion blur samples per frame for Classic 3D layers, shape layers, and certain effects. This corresponds to the Samples Per Frame setting in the Advanced tab of the Composition Settings dialog box.

Type: Integer (between 2 and 64); read/write.

numLayers attribute

Syntax: app.project.item(index).numLayers

Description: The number of layers in the composition.

Type: Integer; read-only.

openInViewer() method

Syntax: app.project.item(index).openInViewer()

Description: Opens the composition in a Composition panel, and moves the Composition panel to front and gives it focus.

Parameters: None.

Returns: Viewer object for the Composition panel, or null if the composition could not be opened.

preserveNestedFrameRate attribute

Syntax: app.project.item(index).preserveNestedFrameRate

Description: When true, the frame rate of nested compositions is preserved in the current composition. Corresponds to the value of the “Preserve frame rate when nested or in render queue” option in the Advanced tab of the Composition Settings dialog box.

Type: Boolean; read/write.

preserveNestedResolution attribute

Syntax: app.project.item(index).preserveNestedResolution

Description: When true, the resolution of nested compositions is preserved in the current composition. Corresponds to the value of the “Preserve Resolution When Nested” option in the Advanced tab of the Composition Settings dialog box.

Type: Boolean; read/write.

renderer attribute

Syntax: app.project.item(index).renderer

Description: The current rendering plug-in module to be used to render this composition, as set in the Advanced tab of the Composition Settings dialog box. Allowed values are the members of compItem.renderers.

Type: String; read/write.

renderers attribute

Syntax: app.project.item(index).renderers

Description: The available rendering plug-in modules. Member strings reflect installed modules, as seen in the Advanced tab of the Composition Settings dialog box.

Type: Array of strings; read-only.

resolutionFactor attribute

Syntax: app.project.item(index).resolutionFactor

Description: The x and y downsample resolution factors for rendering the composition. The two values in the array specify how many pixels to skip when sampling; the first number controls horizontal sampling, the second controls vertical sampling. Full resolution is [1,1], half resolution is [2,2], and quarter resolution is [4,4]. The default is [1,1].

Type: Array of two integers in the range [1..99]; read/write.

selectedLayers attribute

Syntax: app.project.item(index).selectedLayers

Description: All of the selected layers in this composition. This is a 0-based array (the first object is at index 0).

Type: Array of Layer objects; read-only.

selectedProperties attribute

Syntax: app.project.item(index).selectedProperties

Description: All of the selected properties (Property and PropertyGroup objects) in this composition. The first property is at index position 0.

Type: Array of Property and PropertyGroup objects; read-only.

shutterAngle attribute

Syntax: app.project.item(index).shutterAngle

Description: The shutter angle setting for the composition. This corresponds to the Shutter Angle setting in the Advanced tab of the Composition Settings dialog box.

Type: Integer in the range [0...720]; read/write.

shutterPhase attribute

Syntax: app.project.item(index).shutterPhase

Description: The shutter phase setting for the composition. This corresponds to the Shutter Phase setting in the Advanced tab of the Composition Settings dialog box.

Type: Integer in the range [–360...360]; read/write.

workAreaDuration attribute

Syntax: app.project.item(index).workAreaDuration

Description: The duration of the work area in seconds. This is the difference of the start-point and end-point times of the Composition work area.

Type: Floating-point; read/write.

workAreaStart attribute

Syntax: app.project.item(index).workAreaStart

Description: The time when the Composition work area begins, in seconds.

Type: Floating-point; read/write.