after-effects-scripting-guide icon indicating copy to clipboard operation
after-effects-scripting-guide copied to clipboard

Add undocumented Layer.savePreset(File) method

Open zlovatt opened this issue 1 year ago • 1 comments

  • Available on all Layer types (not just AVLayer)
  • Added some time after 23.6.9 (see below)
AE Version Available?
23.6.9 no
24.2.1 yes
24.6.2 yes

Would appreciate if others could check more AE builds between the two above to narrow down when it was added.

As an aside, this should also be added into the types-for-adobe project.

zlovatt avatar Oct 15 '24 15:10 zlovatt

Here's a quick lil snippet to check; just run it in your AE version:

(function checkLayerSavePreset () {
  app.beginUndoGroup("Layer.savePreset Version Check");

  var comp = app.project.items.addComp("Test", 4, 4, 1, 1, 24);
  var lyr = comp.layers.addShape();

  var tempFilePath = Folder.desktop.fsName + "/_tempFile.ffx";
  var tempFile = new File(tempFilePath);
  var exists = false;

  try {
    lyr.savePreset(tempFile);
    exists = true;
  } catch (e) {}

  comp.remove();
  tempFile.remove();
  app.endUndoGroup();

  if (exists) {
    alert("Layer.savePreset() exists in " + String(app.version));
  } else {
    alert("Layer.savePreset() does not exist in " + String(app.version));
  }
})();

zlovatt avatar Oct 15 '24 15:10 zlovatt