From 74b842cc45f239a27742c7bca54ed049bb5494e4 Mon Sep 17 00:00:00 2001 From: Nigel Ihza Firdausy <106657905+Ni-zav@users.noreply.github.com> Date: Sun, 11 Oct 2026 21:30:18 +0700 Subject: [PATCH] fix(script): expose AVLayer transform property shortcuts (#816) --- crates/script/src/prelude.js | 5 +++++ crates/script/src/tests.rs | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/crates/script/src/prelude.js b/crates/script/src/prelude.js index f50a968c..7195835f 100644 --- a/crates/script/src/prelude.js +++ b/crates/script/src/prelude.js @@ -1117,6 +1117,11 @@ AVLayer.prototype.constructor = AVLayer; var P = AVLayer.prototype; function def(name, get, set) { Object.defineProperty(P, name, { get: get, set: set }); } def("source", function () { return __item(this.__info().source); }); + // After Effects exposes the most common Transform properties directly on AVLayer. + // Return the original Property object, not its current value: scripts can keyframe it. + ["anchorPoint", "position", "scale", "rotation", "opacity"].forEach(function (name) { + def(name, function () { return this.transform[name]; }); + }); def("width", function () { return this.__info().width; }); def("height", function () { return this.__info().height; }); def("threeDLayer", function () { return this.__info().threeDLayer; }, function (v) { this.__switch("threeD", v); }); diff --git a/crates/script/src/tests.rs b/crates/script/src/tests.rs index b50a7bfb..dacfe5de 100644 --- a/crates/script/src/tests.rs +++ b/crates/script/src/tests.rs @@ -730,3 +730,23 @@ fn import_options_sequence_picks_one_still_or_the_run() { assert_eq!(kind_of(&s, "shot_[0001-0003].png"), FootageKind::Sequence); let _ = std::fs::remove_dir_all(&dir); } + +#[test] +fn script_av_layer_transform_shortcuts_return_live_properties() { + let mut s = session(); + let o = ok( + &mut s, + r#" + var c = app.project.items.addComp("Shortcuts", 100, 100, 1, 5, 25); + var l = c.layers.addSolid([1, 0, 0], "S", 10, 10, 1); + l.position.setValue([30, 40]); + l.rotation.setValueAtTime(1, 45); + [l.position.value[0], l.transform.position.value[1], l.rotation.numKeys, + l.opacity === undefined, l.scale === undefined, l.anchorPoint === undefined] + "#, + ); + assert_eq!(o.result, json!([30, 40, 1, false, false, false])); + s.undo(); + let restored = ok(&mut s, "app.project.item(1).layer(1).rotation.numKeys"); + assert_eq!(restored.result, json!(0)); +}