Copy link to clipboard
Copied
Is it possible to copy comp markers to the corresponding layer using ExtendScript? Manually this is done by creating a “dummy” marker on the layer, right-clicking it and then selecting “update markers from source”.
You can do ths with app.executeCommand(number returned by find); and app.findMenuCommandId(string);
The way most of these work are the same if you was to do it manually. E.g. To update markers you need to have the layer selected, then Layer > Markers > Update... So you need to do the same in script.
Also if a layer that isn't a comp and is selected that menu would be greyed out same will happen with scripting.
app.beginUndoGroup("Update Markers From Source");
layers = app.project.activeItem.la
...
Copy link to clipboard
Copied
You can do ths with app.executeCommand(number returned by find); and app.findMenuCommandId(string);
The way most of these work are the same if you was to do it manually. E.g. To update markers you need to have the layer selected, then Layer > Markers > Update... So you need to do the same in script.
Also if a layer that isn't a comp and is selected that menu would be greyed out same will happen with scripting.
app.beginUndoGroup("Update Markers From Source");
layers = app.project.activeItem.layers;
app.executeCommand(app.findMenuCommandId("Deselect All")); //Make sure non comp items are selected
for(var i = 1; i <= layers.length; i++){
if (layers[i].source instanceof CompItem){ //Make sure layer is a comp
layers[i].selected = true;
app.executeCommand(app.findMenuCommandId("Update Markers From Source"));
layers[i].selected = false;
}
}
app.endUndoGroup();
Copy link to clipboard
Copied
Thank you. This is a very useful advice. I tried it and it works if I manually open the comp in AE and then run the script.
In my case, I’m creating a lot of comps dynamically and adding layers to them without doing anything manually in AE:
var newComp = compTemplate.duplicate();
var newLayer = newComp.layers.add(some_comp_with_markers);
if (newLayer instanceof AVLayer) {
newLayer.selected = true;
var command = app.findMenuCommandId("Update Markers From Source")
var result = app.executeCommand(command);
newLayer.selected = false;
}
For some reason calling executeCommand() doesn’t do anything.
Copy link to clipboard
Copied
Thank you. This is a very useful advice. I tried it and it works if I manually open the comp in AE and then run the script.
In my case, I’m creating a lot of comps dynamically and adding layers to them without doing anything manually in AE:
var newComp = compTemplate.duplicate(); var newLayer = newComp.layers.add(some_comp_with_markers); if (newLayer instanceof AVLayer) { newLayer.selected = true; var command = app.findMenuCommandId("Update Markers From Source") var result = app.executeCommand(command); newLayer.selected = false; }
For some reason calling executeCommand() doesn’t do anything.
Copy link to clipboard
Copied
Because of the way execute commands work you'll need
newLayer.openInViewer();
near the beginning so the selected = true can work.
Copy link to clipboard
Copied
That's what I was missing. Thank you so much!