Composition
CompItem
¶
Bases: AVItem
The CompItem object represents a composition, and allows you to
manipulate and get information about it.
Example
Info
Item is the base class for AVItem object and for FolderItem object, which are in turn the base classes for various other item types, so Item attributes and methods are available when working with all of these item types.
See: https://ae-scripting.docsforadobe.dev/item/compitem/
Attributes¶
active_camera
¶
active_camera: CameraLayer | None
The front-most enabled camera layer, or None.
Returns the first CameraLayer that is active at the current
composition time. The value is None when the composition
contains no active camera layers.
adjustment_layers
¶
A list of the adjustment layers in this composition.
bg_color
¶
The background color of the composition. The three array values specify the red, green, and blue components of the color. Read / Write.
composition_layers
¶
A list of the composition layers whose source are compositions.
display_start_frame
¶
display_start_frame = ChunkField[int](
"_cdta",
"display_start_frame",
validate=_validate_number(
min=lambda self: int(-10800.0 * frame_rate),
max=lambda self: int(86339.0 * frame_rate),
integer=True,
),
)
The frame value of the beginning of the composition. Read / Write.
display_start_time
¶
display_start_time = ChunkField[float](
"_cdta",
"display_start_time",
validate=_validate_number(min=-10800.0, max=86339.0),
)
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. Read / Write.
draft3d
¶
draft3d = ChunkField[bool]('_cdta', 'draft3d')
When True, Draft 3D mode is enabled for the composition.
Read / Write.
Warning
Deprecated in After Effects 2024 in favor of the new Draft 3D mode.
drop_frame
¶
When True, timecode is displayed in drop-frame format. Only
applicable when frameRate is 29.97 or 59.94. Read / Write.
duration
¶
duration = ChunkField[float](
"_cdta", "duration", validate=validate_duration
)
The duration of the item in seconds. Read / Write.
footage_layers
¶
A list of the composition layers whose source are footages.
frame_blending
¶
frame_blending = ChunkField[bool]("_cdta", "frame_blending")
When True, frame blending is enabled for this Composition. Corresponds
to the value of the Frame Blending button in the Composition panel.
Read / Write.
frame_duration
¶
frame_duration = ChunkField[int](
"_cdta",
"frame_duration",
validate=_validate_number(
min=1,
max=lambda self: int(duration * frame_rate),
integer=True,
),
)
The duration of the item in frames. Read / Write.
frame_rate
¶
frame_rate = ChunkField[float](
"_cdta", "frame_rate", validate=validate_frame_rate
)
The frame rate of the item in frames-per-second. Read / Write.
frame_time
¶
frame_time = ChunkField[int](
"_cdta",
"frame_time",
validate=_validate_number(
min=lambda self: display_start_frame,
max=lambda self: (
display_start_frame + frame_duration - 1
),
integer=True,
),
)
The current time of the item when it is being previewed directly from the Project panel. This value is a number of frames. Read / Write.
guides
¶
The item's ruler guides. Each guide has an orientation and a pixel position. Read-only.
has_audio
¶
has_audio: bool
When True, the composition has an audio component.
A composition has audio when at least one of its layers has a source with audio. Read-only.
has_video
¶
has_video: bool
True if the item has a video component.
An AVItem has video when it has non-zero dimensions (width > 0
and height > 0). In a CompItem, the value is always True.
In a FootageItem,
the value depends on the footage source (e.g. audio-only files
return False).
height
¶
height = ChunkField[int](
"_cdta", "height", validate=validate_footage_dimension
)
The height of the item in pixels. Read / Write.
hide_shy_layers
¶
hide_shy_layers = ChunkField[bool](
"_cdta", "hide_shy_layers"
)
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. Read / Write.
id
¶
id = ChunkField[int](
"_idta", "item_id", read_only=True, default=0
)
The item unique identifier. Read-only.
label
¶
label = enum(Label, '_idta', 'label', default=NONE)
The label color. Colors are represented by their number (0 for None, or 1 to 16 for one of the preset colors in the Labels preferences). Read / Write.
layers_by_id
¶
Map of layer ID to layer, for O(1) lookup by sibling layers.
markers
¶
markers: list[MarkerValue]
A flat list of MarkerValue objects for this composition.
Shortcut for accessing marker data without navigating the property tree. Returns an empty list when the composition has no markers.
motion_blur
¶
motion_blur = ChunkField[bool]('_cdta', 'motion_blur')
When True, motion blur is enabled for the composition. Corresponds
to the value of the Motion Blur button in the Composition panel.
Read / Write.
motion_blur_adaptive_sample_limit
¶
motion_blur_adaptive_sample_limit = ChunkField[int](
"_cdta",
"motion_blur_adaptive_sample_limit",
validate=_validate_number(
min=lambda self: motion_blur_samples_per_frame,
max=256,
integer=True,
),
)
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. Must be >= samples_per_frame.
Read / Write.
motion_blur_samples_per_frame
¶
motion_blur_samples_per_frame = ChunkField[int](
"_cdta",
"motion_blur_samples_per_frame",
validate=_validate_number(min=2, max=64, integer=True),
)
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. Read / Write.
motion_graphics_controllers
¶
motion_graphics_controllers: list[
EssentialGraphicsController
]
The Essential Graphics controllers for this composition. Read-only.
motion_graphics_template_controller_count
¶
motion_graphics_template_controller_count: int
The number of properties in the Essential Graphics panel for the composition. Read-only.
motion_graphics_template_controller_names
¶
The names of all properties in the Essential Graphics panel. Read-only.
motion_graphics_template_name
¶
motion_graphics_template_name: str | None
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. Read / Write.
name
¶
name = ChunkField[str](
"_name_utf8", "value", validate=validate_name
)
The name of the item, as shown in the Project panel. Read / Write.
parent_folder
¶
parent_folder: FolderItem | None
The parent folder of this item. None for the root folder.
Read / Write.
Setting this moves the item into another folder. The item's binary
chunk block is relocated from the old folder's container to the end
of the new folder's container, and both folders' items lists are
updated.
Raises:
-
ValueError–If this is the root folder, or if moving a folder into itself or one of its own descendants.
-
TypeError–If the value is not a FolderItem.
pixel_aspect
¶
pixel_aspect = ChunkField[float](
"_cdta", "pixel_aspect", validate=validate_pixel_aspect
)
The pixel aspect ratio of the item (1.0 is square). Read / Write.
placeholder_layers
¶
A list of the layers whose source are placeholders.
preserve_nested_frame_rate
¶
preserve_nested_frame_rate = ChunkField[bool](
"_cdta", "preserve_nested_frame_rate"
)
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. Read / Write.
preserve_nested_resolution
¶
preserve_nested_resolution = ChunkField[bool](
"_cdta", "preserve_nested_resolution"
)
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. Read / Write.
proxy_source
¶
proxy_source: (
FileSource | SolidSource | PlaceholderSource | None
)
The FootageSource being used as a proxy. Read-only.
To change it, call any of the AVItem methods that change the proxy
source: set_proxy(), set_proxy_with_sequence(),
set_proxy_with_solid(), or set_proxy_with_placeholder().
renderer
¶
renderer: str
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 renderers.
Read / Write.
resolution_factor
¶
resolution_factor = ChunkField[List[int]](
"_cdta",
"resolution_factor",
validate=validate_sequence(
length=2, min=1, max=99, integer=True
),
)
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]. Read / Write.
selected
¶
selected: bool
When True, this item is selected. Read-only.
Note
Item selection is not stored in the .aep binary format; it is a
runtime-only state. Parsed projects always report False.
shutter_angle
¶
shutter_angle = ChunkField[int](
"_cdta",
"shutter_angle",
validate=_validate_number(min=0, max=720, integer=True),
)
The shutter angle setting for the composition. This corresponds to the Shutter Angle setting in the Advanced tab of the Composition Settings dialog box. Read / Write.
shutter_phase
¶
shutter_phase = ChunkField[int](
"_cdta",
"shutter_phase",
validate=_validate_number(
min=-360, max=360, integer=True
),
)
The shutter phase setting for the composition. This corresponds to the Shutter Phase setting in the Advanced tab of the Composition Settings dialog box. Read / Write.
three_d_model_layers
¶
three_d_model_layers: list[ThreeDModelLayer]
A list of the 3D model layers in this composition.
time
¶
time = ChunkField[float](
"_cdta",
"time_seconds",
validate=_validate_number(
min=lambda self: display_start_time,
max=lambda self: (
display_start_time + duration - 1 / frame_rate
),
),
)
The current time of the item when it is being previewed directly from
the Project panel. This value is a number of seconds. It is an error to set
this value for a FootageItem whose main_source is still. Read / Write.
time_scale
¶
time_scale = ChunkField[float](
"_cdta", "time_scale", read_only=True
)
The time scale, used as a divisor for keyframe time values. Read-only.
type_name
¶
type_name: str
A user-readable name for the item type ("Folder", "Footage" or "Composition"). These names are application locale-dependent, meaning that they are different depending on the application's UI language. Read-only.
use_proxy
¶
use_proxy = ChunkField[bool](
"_idta",
"use_proxy",
validate=_validate_use_proxy,
post_set=_sync_proxy_active,
)
When True, a proxy is used for the item. Read / Write.
It is set to True by all the set_proxy methods, and to False by
the set_proxy_to_none() method.
width
¶
width = ChunkField[int](
"_cdta", "width", validate=validate_footage_dimension
)
The width of the item in pixels. Read / Write.
work_area_duration
¶
work_area_duration = ChunkField[float](
"_cdta",
"work_area_duration",
validate=_validate_number(
min=lambda self: 1 / frame_rate,
max=lambda self: duration - work_area_start,
),
)
The work area duration in seconds. Read / Write.
work_area_duration_frame
¶
work_area_duration_frame = ChunkField[int](
"_cdta",
"work_area_duration_frame",
validate=_validate_number(
min=1,
max=lambda self: (
frame_duration - work_area_start_frame
),
integer=True,
),
)
The work area duration in frames. Read / Write.
work_area_start
¶
work_area_start = ChunkField[float](
"_cdta",
"work_area_start",
validate=_validate_number(
min=0.0, max=lambda self: duration - 1 / frame_rate
),
)
The work area start time relative to composition start. Read / Write.
work_area_start_frame
¶
work_area_start_frame = ChunkField[int](
"_cdta",
"work_area_start_frame",
validate=_validate_number(
min=0,
max=lambda self: frame_duration - 1,
integer=True,
),
)
The work area start frame relative to composition start. Read / Write.
Functions¶
add
¶
add_box_text
¶
add_camera
¶
add_camera(
name: str | None = None,
center_point: list[float] | None = None,
) -> CameraLayer
Create a new camera layer at the top of the layer stack.
Parameters:
-
name(str | None, default:None) –Layer name. Auto-generated if
None. -
center_point(list[float] | None, default:None) –The
[x, y]center point. Defaults to[width/2, height/2].
Returns:
-
CameraLayer–The newly created CameraLayer.
add_guide
¶
add_light
¶
add_light(
name: str | None = None,
center_point: list[float] | None = None,
) -> LightLayer
Create a new light layer at the top of the layer stack.
Parameters:
-
name(str | None, default:None) –Layer name. Auto-generated if
None. -
center_point(list[float] | None, default:None) –The
[x, y]center point. Defaults to[width/2, height/2].
Returns:
-
LightLayer–The newly created LightLayer.
add_null
¶
Create a new null layer at the top of the layer stack.
A null layer has no visual content and is commonly used as a parent for other layers. Its source is a small transparent solid created automatically.
Parameters:
-
duration(float | None, default:None) –Layer duration in seconds. Defaults to the composition duration.
Returns:
add_shape
¶
add_shape() -> ShapeLayer
Create a new empty shape layer at the top of the layer stack.
Returns:
-
ShapeLayer–The newly created ShapeLayer.
add_solid
¶
add_solid(
color: list[float],
name: str | None = None,
width: int | None = None,
height: int | None = None,
pixel_aspect: float = 1.0,
duration: float | None = None,
) -> AVLayer
Create a new solid layer at the top of the layer stack.
Parameters:
-
color(list[float]) –Solid color as
[R, G, B]in 0.0--1.0 range. -
name(str | None, default:None) –The solid and layer name. Pass
Noneto auto-generate a name from the color (e.g.Red Solid 1). -
width(int | None, default:None) –Solid width in pixels. Defaults to comp width.
-
height(int | None, default:None) –Solid height in pixels. Defaults to comp height.
-
pixel_aspect(float, default:1.0) –Pixel aspect ratio (default 1.0).
-
duration(float | None, default:None) –Layer duration in seconds. Defaults to comp duration.
Returns:
add_text
¶
add_vertical_box_text
¶
Create a new vertical box (paragraph) text layer at the top of the stack.
Vertical text flows top-to-bottom with lines stacking right-to-left, matching the Vertical Type Tool default.
Parameters:
-
box_size(list[float] | None, default:None) –[width, height]of the text box. IfNone, uses the composition dimensions. -
text(str, default:'') –Initial text content.
Returns:
add_vertical_text
¶
layer
¶
layer(
name: str | None = None,
index: int | None = None,
other_layer: Layer | None = None,
rel_index: int | None = None,
) -> Layer
Get a Layer object by name, index, or relative to another layer.
Parameters:
-
name(str | None, default:None) –The name of the layer to return.
-
index(int | None, default:None) –The index position of the layer to return.
-
other_layer(Layer | None, default:None) –A Layer object to use as a reference for the relative index position of the layer to return.
-
rel_index(int | None, default:None) –The index position of the layer relative to the other_layer to return.
remove_guide
¶
remove_guide(guide_index: int) -> None
Removes an existing guide by index.
Parameters:
-
guide_index(int) –The 0-based index of the guide to remove.
Raises:
-
IndexError–If
guide_indexis out of range.
set_proxy
¶
Sets a file as the proxy of this AVItem.
Loads the specified file into a new FileSource object, sets this as the value
of the proxy_source attribute, and sets use_proxy to true.
It does not preserve the interpretation parameters, instead using the user preferences.
This differs from setting a FootageItem's main_source, but both actions are
performed as in the user interface.
Note
Unlike ExtendScript, if the specified file has an unlabeled alpha channel, this method does not estimate the alpha interpretation.
Parameters:
Raises:
-
ValueError–If the extension is not a supported footage format.
-
NotImplementedError–If After Effects requires a format-specific
optiheader not implemented for this format.
set_proxy_with_placeholder
¶
set_proxy_with_placeholder(
name: str | None,
width: int,
height: int,
frame_rate: float,
duration: float,
) -> None
Set a placeholder as the proxy source.
Parameters:
set_proxy_with_sequence
¶
Sets a sequence of files as the proxy of this AVItem, with the option of
forcing alphabetical order. Loads the specified file sequence into a new
FileSource object, sets this as the value of the proxy_source attribute, and
sets use_proxy to true.
It does not preserve the interpretation parameters, instead using the user preferences.
Note
Unlike ExtendScript, if the specified file has an unlabeled alpha channel, this method does not estimate the alpha interpretation.
Parameters:
-
file(str | PathLike[str]) –Path to a representative frame; sibling frames in the same folder are gathered into the sequence.
-
force_alphabetical(bool, default:False) –Order frames alphabetically rather than numerically.
Raises:
-
ValueError–If the extension is not a supported footage format.
-
NotImplementedError–If After Effects requires a format-specific
optiheader not implemented for this format.
set_proxy_with_solid
¶
set_proxy_with_solid(
color: list[float],
name: str | None,
width: int,
height: int,
pixel_aspect: float = 1.0,
) -> None
Set a solid as the proxy source.
Parameters:
-
color(list[float]) –Solid color as [R, G, B] in 0.0-1.0 range.
-
name(str | None) –The solid name. Pass
Noneto auto-generate a name from the color (e.g.Red Solid 1). An empty string becomes????. -
width(int) –Width in pixels (1-30000).
-
height(int) –Height in pixels (1-30000).
-
pixel_aspect(float, default:1.0) –Pixel aspect ratio (0.01-100.0).