Scripts: pageItems lists the art inside blends, envelopes, repeats and intertwines

pageItems walked into groups and compound paths only, so the objects inside a blend,
an envelope, a repeat or an intertwine were missing from length, [i], index and
getByName, although each of them reports that container as its parent. The walk now
goes into every container's children.
This commit is contained in:
dotCooCoo committed 2026-11-22 15:33:08 -08:00
1 parent 3d460c1697
commit dc9adb195d
3 files changed
+22 -4

No files matched your search

+4 -3
View File
@@ -397,11 +397,12 @@ fn page_items(h: &Host, st: &DocState) -> Rc<Vec<NodeId>> {
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),
}
}
}
+15
View File
@@ -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();
+3 -1
View File
@@ -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