• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to “update markers from source” using ExtendScript?

Engaged ,
Oct 18, 2020 Oct 18, 2020

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

TOPICS
How to , Scripting

Views

764

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Oct 18, 2020 Oct 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.la
...

Votes

Translate

Translate
Explorer ,
Oct 18, 2020 Oct 18, 2020

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 18, 2020 Oct 18, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 18, 2020 Oct 18, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 18, 2020 Oct 18, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 18, 2020 Oct 18, 2020

Copy link to clipboard

Copied

LATEST

That's what I was missing. Thank you so much!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines