Hello!
I am trying to add a local file to selected comps, fit it to width, then make it a guide layer all at once - is this possible?
Thank you!
Greg
Moderator: byronnash
Hello!
I am trying to add a local file to selected comps, fit it to width, then make it a guide layer all at once - is this possible?
Thank you!
Greg
Code: Select all
function importGuide() {
var comps = app.project.selection;
var myFile, i, myItem, comp, myLayer;
var myFilePath = ''; // insert path here or..
if (myFilePath) {
myFile = new File(myFilePath);
} else {
myFile = File.openDialog(); // ..select file instead
}
var importedFile = app.project.importFile(new ImportOptions(myFile));
// Find the item number of the imported file
for (i = 1; i <= app.project.numItems; i++) {
if (app.project.item(i).name === importedFile.name) {
myItem = i;
break;
}
}
for (i = 0; i < comps.length; i++) {
comp = comps[i];
// Open comp in order for Fit to Comp To Work
comp.openInViewer();
// If found add item to comp
if (myItem) {
myLayer = comp.layers.add(app.project.item(myItem));
}
// Fit to comp width
app.executeCommand(app.findMenuCommandId('Fit to Comp Width'));
// Make guide layer
myLayer.guideLayer = true;
}
}
importGuide();