- November 18, 2019 at 2:48 am
Hello, I have a script that imports a bunch of files, creates folders and subfolders and changes comp names. So far so good, but the problem is that I also want to change one of the layers (a picture) and replace it, on each composition, with a specific picture.
I have several functions to get the layers that should be replaced and the FootageItems that they should be replaced with. However, this doesn’t seem to work with replaceSource (I get an Function item.layer is undefined error).
If i explicitly declare the project item and the project layer, the replacement works, but I need to get these from functions that return the objects.
I have attached a simplified version of the code that gives me the same error.
Thank you very much.
var myProject = app.project;
var item = myProject.item(1);
var layer = item.layer(1);
var replace = myProject.item(2);
layer.replaceSource (replace, false);
- November 18, 2019 at 11:41 am
This may happen if after importing files and creating folders your comp’s index has changed and item(1) now is not a comp but some footage or folder (which don’t have a layer() function and thus the error).
- November 18, 2019 at 3:20 pm
This is not the case, as no new items are being created in this test code.
Also, as a side note, in the code of the original post, if the var is not named “item” (which could cause some confusion) I still get the same error.
- November 18, 2019 at 6:27 pm
Have you checked if the comp is really the item(1)?
Log in to reply.