diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index 8079107fd8..cb901014b5 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -397,11 +397,12 @@ fn page_items(h: &Host, st: &DocState) -> Rc> { match &n.kind { NodeKind::Layer { children, .. } => walk(children, out), NodeKind::RulerGuide { .. } => {} - NodeKind::Group { children, .. } | NodeKind::Compound { children, .. } => { + _ => { out.push(n.id); - walk(children, out); + if let Some(children) = n.children() { + walk(children, out); + } } - _ => out.push(n.id), } } } diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index e80e973626..60e3a71521 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -100,6 +100,21 @@ fn page_items_are_live_and_typed_for_all_node_kinds() { ); } +#[test] +fn page_items_list_the_art_inside_a_blend() { + let (mut s, a, b) = doc(); + log(&mut s, "app.activeDocument.pageItems[0].name = 'first';"); + s.execute("object.blend.make", &json!({"ids": [a.0, b.0], "steps": 2})).unwrap(); + let out = log( + &mut s, + "var p = app.activeDocument.pageItems, t = [];\ + for (var i = 0; i < p.length; i++) t.push(p[i].typename);\ + vc.log(t.join(','));\ + vc.log(p.getByName('first').parent.typename); vc.log(p.index('first').typename);", + ); + assert_eq!(out, vec![json!("BlendItem,PathItem,PathItem"), json!("BlendItem"), json!("PathItem")]); +} + #[test] fn page_item_geometry_uses_document_coordinates_with_y_up() { let (mut s, _, _) = doc(); diff --git a/docs/mcp.md b/docs/mcp.md index c805cacaa9..4685f408d7 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2643,7 +2643,9 @@ app through the global object `vc`, and writes to the Script Console and runs ot `showOptionsDialog` true throws `Dialog unavailable` with no document made. A `Document` (https://ai-scripting.docsforadobe.dev/jsobjref/Document/) has `name`, `width`, `height`, `rulerUnits`, `documentColorSpace`, `rulerOrigin`, `convertCoordinate(point, source, destination)`, `pageItems` and `selection`. `pageItems` (https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/) - has `length`, `[i]`, `index(key)`, `getByName(name)` and `removeAll()`; `i in` either collection is true for each + lists every object in the document's layers, the objects inside groups, compound paths, blends, envelopes, repeats + and intertwines included, and has `length`, `[i]`, `index(key)`, `getByName(name)` and `removeAll()`; `i in` either + collection is true for each entry `[i]` gives. Each page item (https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/) has `typename`, `parent`, `name`, `note` (the Attributes panel's note, trimmed as `attributes.set` trims it), `hidden`, `locked`, `selected` (assigning it adds