Skip to main content
Inspiring
October 18, 2020
Answered

How to “update markers from source” using ExtendScript?

  • October 18, 2020
  • 1 reply
  • 1408 views

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”.

This topic has been closed for replies.
Correct answer Greg5F9B

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();

 

1 reply

Greg5F9BCorrect answer
Participating Frequently
October 18, 2020

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();

 

Inspiring
October 18, 2020

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.