ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Change image source of a layer (Script)

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sergey MakarinChange image source of a layer (Script)
by on Feb 26, 2015 at 12:05:28 am

I know how to change text in text layer (Works fine):

layer.sourceText.setValue(new TextDocument("Text Text Text"));


And need to change an image for image layer. But similarly the code doesn't work:


layer.sourceImage.setValue(new ImageDocument("c://image.jpg"));


Please write me correct code for changing image.


Return to posts index

Walter SoykaRe: Change image source of a layer (Script)
by on Feb 26, 2015 at 1:22:40 am

Use an AVLayer's replaceSource() method:

app.project.item(index).layer(index).replaceSource(newSource, fixExpressions)

The source should be a footage item object, not a file path.

See p. 47 of the Ae CS6 scripting guide for more.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Sergey MakarinRe: Change image source of a layer (Script)
by on Feb 26, 2015 at 1:41:33 am

I think that the code must be like that:

layer.replaceSource(source, true);

but how to correct define "source" var?


Return to posts index


Walter SoykaRe: Change image source of a layer (Script)
by on Feb 26, 2015 at 3:11:50 am

source is an object (AVItem?) from the project panel.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Sergey MakarinRe: Change image source of a layer (Script)
by on Feb 26, 2015 at 10:36:34 am

I found a solution:

source = new ImportOptions(File("c://image.jpg"));
layer.replaceSource(source, true);


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]