Hi all.
Practice using the BridgeTalk class.
Here is a description of the sequence of actions of the script.
Export an Illustrator file to a PSD file.
Opening a PSD file in After Effects.
Copy the layers of the Illustrator file.
Place the copied Illustrator file layer on the After Effects project layer.
Why is only one copied to all the layers in an After Effects file, the last layer mask from the Illustrator file?
----------------------------------------------------------------------------------------------------------------------------------
I wanted to attach a file Draw.ai, but the form does not let it through.
The file contains one layer, inside of which there are 5 layers.
Each of which contains one free-form pathItems.
-----------------------------------------------------------------------------------------------------------------------------------
function F_exportFileToPSD(string) {
if (app.documents.length > 0) {
var exportOptions = new ExportOptionsPhotoshop();
exportOptions.resolution = 72;
exportOptions.imageColorSpace.RGB;
exportOptions.maximumEditability = true;
exportOptions.writeLayers = true;
var type = ExportType.PHOTOSHOP;
var fileSpec = new File(string);
app.activeDocument.exportFile(fileSpec, type, exportOptions);
}
}
// Exporting an Illustrator file to a PSD file.
var fileName = app.activeDocument.name.split(".")[0];
var filePathName = filePath + "/" + fileName + "_PSD.psd"
F_exportFileToPSD(filePathName);
// Opening the PSD file in After Effects.
var ImpFileString = "var ImpFile = \"" + filePathName + "\";";
var bt = new BridgeTalk();
var specifier = "aftereffects";
if (!BridgeTalk.isRunning(specifier)) {
BridgeTalk.launch(specifier);
}
var bt = new BridgeTalk();
bt.target = specifier;
var scp = "app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);";
scp += "ImpFileOpt = new ImportOptions();";
scp += ImpFileString;
scp += "ImpFileOpt.file = new File(ImpFile);";
scp += "ImpFileOpt.importAs = ImportAsType.COMP_CROPPED_LAYERS;";
scp += "app.project.importFile(ImpFileOpt);";
scp += "app.disableRendering =true;";
bt.body = scp;
bt.send();
for (i = 0; i < app.activeDocument.layers.length; i++) {
var carentLayer = app.activeDocument.layers[i].name;
var bt = new BridgeTalk();
var specifier = "aftereffects";
bt.target = specifier;
var scp = 'function F_findeCompItemByName(Name) {\n';
scp += '\tfor (f = 1; f <= app.project.numItems; f++) {;\n';
scp += '\t\tif ((app.project.item(f).name == Name) && (app.project.item(f) instanceof CompItem)){\n';
scp += '\t\t\treturn app.project.item(f);\n';
scp += '\t\t}\n';
scp += '\t}\n';
scp += '}\n';
scp += 'carentComp = F_findeCompItemByName("' + carentLayer + '");\n';
scp += 'carentComp.openInViewer();\n';
bt.body = scp;
bt.send();
for (var j = 1; j <= app.activeDocument.layers[i].layers.length; j++) {
var Ill_layer = j - 1;
app.redraw();
app.activeDocument.layers[i].layers[Ill_layer].hasSelectedArtwork = true;
app.copy(); // Copy layer of an Illustrator file.
app.redraw();
var bt = new BridgeTalk();
var specifier = "aftereffects";
bt.target = specifier;
// Place the copied Illustrator file layer into the After Effects project layer.
scp = 'carentComp.layer(' + j + ').selected = true;\n';
scp += 'app.executeCommand(20);\n';
scp += 'carentComp.layer('+ j + ').selected = false;\n';
bt.body = scp;
bt.send();
app.activeDocument.layers[i].layers[Ill_layer].hasSelectedArtwork = false;
}
var bt = new BridgeTalk();
var specifier = "aftereffects";
bt.target = specifier;
var scp = "app.disableRendering = false;";
bt.body = scp;
bt.send();
}