compitem
CompItem object
Section titled “CompItem object”app.project.item(index)
app.project.items[index]
Description
Section titled “Description”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 object, which is a subclass of Item object. All methods and attributes of AVItem and Item, in addition to those listed below, are available when working with CompItem.
Example
Section titled “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);
Attributes
Section titled “Attributes”CompItem.activeCamera
Section titled “CompItem.activeCamera”app.project.item(index).activeCamera
Description
Section titled “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.
CameraLayer object; read-only.
CompItem.bgColor
Section titled “CompItem.bgColor”app.project.item(index).bgColor
Description
Section titled “Description”The background color of the composition. The three array values specify the red, green, and blue components of the color.
An array containing three floating-point values, [R, G, B]
, in the range [0.0..1.0]
; read/write.
CompItem.counters
Section titled “CompItem.counters”app.project.item(index).counters
This method/property is officially undocumented and was found via research. The information here may be inaccurate, and this whole method/property may disappear or stop working some point. Please contribute if you have more information on it!
Description
Section titled “Description”This attribute works app-wide: if changed on one CompItem, it will change it for every CompItem in the project. The value stays until restarting AE. Once restarted, it will revert to false
.
This parameter doesn’t do anything.
Boolean; read/write.
CompItem.displayStartFrame
Section titled “CompItem.displayStartFrame”app.project.item(index).displayStartFrame
Description
Section titled “Description”The frame value of the beginning of the composition.
This value is an alternative to calculating the start frame using CompItem.displayStartTime and CompItem.frameDuration to compensate for floating-point problems.
Integer; read/write.
CompItem.displayStartTime
Section titled “CompItem.displayStartTime”app.project.item(index).displayStartTime
Description
Section titled “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.
Floating-point valuem in the range [-10800.0..86339.0]
(-3:00:00:00 to 23:59:00:00); read/write.
CompItem.draft3d
Section titled “CompItem.draft3d”app.project.item(index).draft3d
Description
Section titled “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.
Boolean; read/write.
CompItem.dropFrame
Section titled “CompItem.dropFrame”app.project.item(index).dropFrame
Description
Section titled “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.
Boolean; read/write.
CompItem.frameBlending
Section titled “CompItem.frameBlending”app.project.item(index).frameBlending
Description
Section titled “Description”When true
, frame blending is enabled for this Composition. Corresponds to the value of the Frame Blending button in the Composition panel.
Boolean; if true
, frame blending is enabled; read/write.
CompItem.frameDuration
Section titled “CompItem.frameDuration”app.project.item(index).frameDuration
Description
Section titled “Description”The duration of a frame, in seconds. This is the inverse of the frameRate
value (frames-per-second).
Floating-point value; read/write.
CompItem.hideShyLayers
Section titled “CompItem.hideShyLayers”app.project.item(index).hideShyLayers
Description
Section titled “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.
Boolean; read/write.
CompItem.layers
Section titled “CompItem.layers”app.project.item(index).layers
Description
Section titled “Description”A LayerCollection object that contains all the Layer objects for layers in this composition.
LayerCollection object; read-only.
CompItem.markerProperty
Section titled “CompItem.markerProperty”app.project.item(index).markerProperty
Description
Section titled “Description”A PropertyGroup object that contains all a composition’s markers. Composition marker scripting has the same functionality as Layer markers.
See MarkerValue object.
PropertyGroup object or null
; read-only.
Example
Section titled “Example”The following sample code creates a project and composition, then creates two composition markers with different properties
// comp.markerProperty allows you to add markers to a comp.// It has the same functionality as layer.property("Marker")var currentProj = app.newProject();var comp = currentProj.items.addComp("mycomp", 1920, 1080, 1.0, 5, 29.97);var solidLayer = comp.layers.addSolid([1, 1, 1], "mylayer", 1920, 1080, 1.0);
var compMarker = new MarkerValue("This is a comp marker!");compMarker.duration = 1;
var compMarker2 = new MarkerValue("Another comp marker!");compMarker2.duration = 1;
comp.markerProperty.setValueAtTime(1, compMarker);comp.markerProperty.setValueAtTime(3, compMarker2);
CompItem.motionBlur
Section titled “CompItem.motionBlur”app.project.item(index).motionBlur
Description
Section titled “Description”When true
, motion blur is enabled for the composition. Corresponds to the value of the Motion Blur button in the Composition panel.
Boolean; read/write.
CompItem.motionBlurAdaptiveSampleLimit
Section titled “CompItem.motionBlurAdaptiveSampleLimit”app.project.item(index).motionBlurAdaptiveSampleLimit
Description
Section titled “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.
Integer (between 16 and 256); read/write.
CompItem.motionBlurSamplesPerFrame
Section titled “CompItem.motionBlurSamplesPerFrame”app.project.item(index).motionBlurSamplesPerFrame
Description
Section titled “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.
Integer (between 2 and 64); read/write.
CompItem.motionGraphicsTemplateControllerCount
Section titled “CompItem.motionGraphicsTemplateControllerCount”app.project.item(index).motionGraphicsTemplateControllerCount
Description
Section titled “Description”The number of properties in the Essential Graphics panel for the composition.
Integer; read-only.
CompItem.motionGraphicsTemplateName
Section titled “CompItem.motionGraphicsTemplateName”app.project.item(index).motionGraphicsTemplateName
Description
Section titled “Description”Read or write the name property in the Essential Graphics panel for the composition.
The name in the Essential Graphics panel is used for the file name of an exported Motion Graphics template (ex., “My Template.mogrt”).
The following example will set the name for the active composition and then return it as an alert
app.project.activeItem.motionGraphicsTemplateName = "My Template";alert(app.project.activeItem.motionGraphicsTemplateName);
String; read/write.
CompItem.numLayers
Section titled “CompItem.numLayers”app.project.item(index).numLayers
Description
Section titled “Description”The number of layers in the composition.
Integer; read-only.
CompItem.preserveNestedFrameRate
Section titled “CompItem.preserveNestedFrameRate”app.project.item(index).preserveNestedFrameRate
Description
Section titled “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.
Boolean; read/write.
CompItem.preserveNestedResolution
Section titled “CompItem.preserveNestedResolution”app.project.item(index).preserveNestedResolution
Description
Section titled “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.
Boolean; read/write.
CompItem.renderer
Section titled “CompItem.renderer”app.project.item(index).renderer
Description
Section titled “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.
String; read/write.
CompItem.renderers
Section titled “CompItem.renderers”app.project.item(index).renderers
Description
Section titled “Description”The available rendering plug-in modules. Member strings reflect installed modules, as seen in the Advanced tab of the Composition Settings dialog box.
Array of strings; read-only.
CompItem.resolutionFactor
Section titled “CompItem.resolutionFactor”app.project.item(index).resolutionFactor
Description
Section titled “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]
.
Array of two integers in the range [1..99]
; read/write.
CompItem.selectedLayers
Section titled “CompItem.selectedLayers”app.project.item(index).selectedLayers
Description
Section titled “Description”All of the selected layers in this composition. This is a 0-based array (the first object is at index 0).
Array of Layer objects; read-only.
CompItem.selectedProperties
Section titled “CompItem.selectedProperties”app.project.item(index).selectedProperties
Description
Section titled “Description”All of the selected properties (Property and PropertyGroup objects) in this composition. The first property is at index position 0.
Array of Property and PropertyGroup objects; read-only.
CompItem.shutterAngle
Section titled “CompItem.shutterAngle”app.project.item(index).shutterAngle
Description
Section titled “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.
Integer, in the range [0..720]
; read/write.
CompItem.shutterPhase
Section titled “CompItem.shutterPhase”app.project.item(index).shutterPhase
Description
Section titled “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.
Integer, in the range [-360..360]
; read/write.
CompItem.workAreaDuration
Section titled “CompItem.workAreaDuration”app.project.item(index).workAreaDuration
Description
Section titled “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.
Floating-point value; read/write.
CompItem.workAreaStart
Section titled “CompItem.workAreaStart”app.project.item(index).workAreaStart
Description
Section titled “Description”The time when the Composition work area begins, in seconds.
Floating-point value; read/write.
Methods
Section titled “Methods”CompItem.duplicate()
Section titled “CompItem.duplicate()”app.project.item(index).duplicate()
Description
Section titled “Description”Creates and returns a duplicate of this composition, which contains the same layers as the original.
Parameters
Section titled “Parameters”None.
Returns
Section titled “Returns”CompItem object.
CompItem.exportAsMotionGraphicsTemplate()
Section titled “CompItem.exportAsMotionGraphicsTemplate()”app.project.item(index).exportAsMotionGraphicsTemplate(doOverWriteFileIfExisting[, file_path])
Description
Section titled “Description”Exports the composition as a Motion Graphics template. Returns true
if the Motion Graphics template is successfully exported, otherwise false
.
The name in the Essential Graphics panel is used for the file name of the Motion Graphics template (ex., “My Template.mogrt”).
Use the motionGraphicsTemplateName
attribute to set the name.
Optionally specify the path to the folder where the Motion Graphics template file is saved. If not specified, the file will be saved in the current user’s Motion Graphics Templates folder:
OS | Path |
---|---|
macOS | /Users/<name>/Library/Application Support/Adobe/Common/Motion Graphics Templates/ |
Windows | C:\Users\<name>\AppData\Roaming\Adobe\Common\Motion Graphics Templates\ |
If the project has been changed since the last time it was saved, After Effects will prompt the user to save the project. To avoid this, use the
project save()
method before exporting the Motion Graphics template.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
doOverWriteFileIfExisting | Boolean | Whether to overwrite an existing file of the same name. |
file_path | String | Optional. Path to the folder where the file will be saved. |
Returns
Section titled “Returns”Boolean.
CompItem.getMotionGraphicsTemplateControllerName()
Section titled “CompItem.getMotionGraphicsTemplateControllerName()”app.project.item(index).getMotionGraphicsTemplateControllerName(index)
Description
Section titled “Description”Gets the name of a single property in the Essential Graphics panel.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
index | Integer | The index of the EGP property whose name will be returned. |
Returns
Section titled “Returns”String; read-only.
CompItem.setMotionGraphicsControllerName()
Section titled “CompItem.setMotionGraphicsControllerName()”app.project.item(index).setMotionGraphicsControllerName(index, newName)
Description
Section titled “Description”Sets the name of a single property in the Essential Graphics panel.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
index | Integer | The index of the EGP property to be renamed. |
newName | String | The new name for the EGP property. |
Returns
Section titled “Returns”String; read-only.
CompItem.layer()
Section titled “CompItem.layer()”app.project.item(index).layer(index)
app.project.item(index).layer(otherLayer, relIndex)
app.project.item(index).layer(name)
Description
Section titled “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
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
index | Integer, in the range [1..numLayers] , where numLayers is the number of layers in the composition | The index number of the desired layer in this composition. |
or:
Parameter | Type | Description |
---|---|---|
otherLayer | 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 | Integer, in the range [1 - otherLayer.index .. numLayers - otherLayer.index] , where numLayers is the number of layers in the composition. | The position of the desired layer, relative to otherLayer . This value is added to the otherLayer value to derive the absolute index of the layer to return. |
or:
Parameter | Type | Description |
---|---|---|
name | String | The name of the desired layer. |
Returns
Section titled “Returns”CompItem.openInEssentialGraphics()
Section titled “CompItem.openInEssentialGraphics()”app.project.item(index).openInEssentialGraphics()
Description
Section titled “Description”Opens the composition in the Essential Graphics panel.
Parameters
Section titled “Parameters”None.
Returns
Section titled “Returns”Nothing.
CompItem.openInViewer()
Section titled “CompItem.openInViewer()”app.project.item(index).openInViewer()
Description
Section titled “Description”Opens the composition in a Composition panel, and moves the Composition panel to front and gives it focus.
Parameters
Section titled “Parameters”None.
Returns
Section titled “Returns”Viewer object object for the Composition panel, or null
if the composition could not be opened.