comp importing script not working properly
Copy link to clipboard
Copied
hello guys, i am trying to make an extension to import project and add its comp to the timeline, however it only works well when i select the timeline or comp panel, if project panel is selected it import the project without adding its comp to my timeline.. any help will be appreciated , thanks..
here is my code
function Generate() {
// Get a reference to the current project
var project = app.project;
// Specify the path to the project file containing the composition you want to import
var filePath = "C:/Users/mhmood/Documents/test.aep";
// Import the project file and get a reference to the imported project item
var importedProjectItem = project.importFile(new ImportOptions(File(filePath)));
// Get the first composition in the imported project
var importedComp = importedProjectItem.item(1);
// Create a new layer for the imported composition
var layer = app.project.activeItem.layers.add(importedComp);
// Set the in and out points of the layer to match the duration of the current composition
layer.startTime = project.activeItem.time;
}
$._ext = {
generateComComp: function() {
Generate();
}
};
Copy link to clipboard
Copied
This line:
var layer = app.project.activeItem.layers.add(importedComp);
expects that you have a comp opened as the active item. I'm not sure what the alternative is. If you know the name of the comp, I guess you could find that comp in the project bin and do comp.openInViewer().
Copy link to clipboard
Copied
the comp is opened but the script doen't recognize it as open unless the copm panel is selected
Copy link to clipboard
Copied
Exactly. Unless it's the active item.

