mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 21:42:59 -05:00
Scripts: perspective grid members and getPresetSettings for scripts
A document in the script object model can now show and hide its perspective grid, read and set the active plane, and reset the grid to a built-in or saved preset, as the Document page lists them (https://ai-scripting.docsforadobe.dev/jsobjref/Document/). The values come from the PerspectiveGridType and PerspectiveGridPlaneType enumerations on the scripting constants page. app.getPresetSettings returns a new DocumentPreset with the settings that a document made from the named startup preset starts with, and addDocument accepts it back without changes. - showPerspectiveGrid, hidePerspectiveGrid and setActivePlane run perspective.grid.show and perspective.plane.set. They add no undo step, and a failed run restores the grid. A run that only changes the grid's view state no longer adds an undo step. A run in which a command records its own undo step still adds one. - selectPerspectivePreset throws, and leaves the grid unchanged, when the preset name is not listed, when the preset's grid is not of gridType, when gridType is InvalidPerspectiveGridType, and when the name is longer than 4,096 bytes. A one-point grid accepts only the left and floor planes. - The workspace methods, loadColorSettings, showPresets and the perspective grid preset file methods throw an error that says they are not available yet. Docs: docs/mcp.md, docs/target-app-parity.md.
This commit is contained in:
1 parent
185517dac1
commit
9ffec7e72d
10 files changed
+607
-3
No files matched your search
+26
@@ -2728,6 +2728,32 @@ app through the global object `vc`, and writes to the Script Console and runs ot
|
||||
`RangeError`. A layer that was deleted throws `Stale layer`, and an artboard that was deleted throws
|
||||
`Stale artboard`. `Layer.pathItems`, `blendingMode`, `artworkKnockout` and `sliced`, `GroupItem.pathItems` and
|
||||
`GroupItems.createFromFile` throw an error that says they are not available yet.
|
||||
- A document also has `showPerspectiveGrid()`, `hidePerspectiveGrid()`, `getPerspectiveActivePlane()`,
|
||||
`setActivePlane(gridPlane)` and `selectPerspectivePreset(gridType, presetName)`
|
||||
(https://ai-scripting.docsforadobe.dev/jsobjref/Document/), and `app` has `getPresetSettings(preset)`
|
||||
(https://ai-scripting.docsforadobe.dev/jsobjref/Application/). `showPerspectiveGrid` and `hidePerspectiveGrid`
|
||||
run `perspective.grid.show`, and `setActivePlane` runs `perspective.plane.set`; none of them adds an undo step, and
|
||||
a failed run puts the grid back. `selectPerspectivePreset` runs `perspective.grid.preset` with a built-in or saved
|
||||
preset of `perspective.presets.list` (its name in any case), which shows the grid and is part of the run's undo
|
||||
step when the grid changes. The enumerations `PerspectiveGridType` (`OnePointPerspectiveGridType`,
|
||||
`TwoPointPerspectiveGridType`, `ThreePointPerspectiveGridType`, `InvalidPerspectiveGridType`) and
|
||||
`PerspectiveGridPlaneType` (`GRIDLEFTPLANETYPE`, `GRIDRIGHTPLANETYPE`, `GRIDFLOORPLANETYPE`,
|
||||
`INVALIDGRIDPLANETYPE`) come from https://ai-scripting.docsforadobe.dev/jsobjref/scripting-constants/. A
|
||||
one-point grid takes only the left and the floor plane as its active plane, as the archived scripting guide
|
||||
describes
|
||||
(https://web.archive.org/web/20170622004549/https://wwwimages.adobe.com/content/dam/Adobe/en/devnet/illustrator/sdk/CC2015_3/AI_ScriptGd.pdf).
|
||||
`getPresetSettings` takes the names `addDocument` takes and gives a new `DocumentPreset` with the settings a
|
||||
document from that preset starts with, which `addDocument` takes back unchanged. It leaves out `units` when the
|
||||
preset's units are not one of the six `RulerUnits` values a new document takes, and `numArtboards` and
|
||||
`artboardRowsOrCols` when the preset has more than 100 artboards, so `addDocument` with the same preset keeps the
|
||||
preset's own.
|
||||
VectorCraft's own rules: `showPerspectiveGrid` and `setActivePlane` give `true`, and `hidePerspectiveGrid` gives
|
||||
`false` when the grid was already hidden. `INVALIDGRIDPLANETYPE` makes no plane active. A preset name that is not
|
||||
listed, a preset whose grid is not of `gridType`, `InvalidPerspectiveGridType` and a name of more than 4,096 bytes
|
||||
throw an error with nothing changed. Changing the `DocumentPreset` `getPresetSettings` gives changes nothing else.
|
||||
`app.saveWorkspace`, `switchWorkspace`, `deleteWorkspace`, `resetWorkspace`, `loadColorSettings` and
|
||||
`showPresets`, and `Document.exportPerspectiveGridPreset` and `importPerspectiveGridPreset`, throw an error that
|
||||
says they are not available yet.
|
||||
- `object.newGroup {parent?, index?}` adds an empty group to a shown, unlocked layer or group (`parent`; default:
|
||||
the current layer), on top of its contents or at `index` (0 is the bottom; in a clipping layer or group, index 0
|
||||
puts it directly above the clipping path), as one undo step named Group, and
|
||||
|
||||
@@ -1026,6 +1026,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`.
|
||||
- Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). Paths, type and the other classes are not there yet, except that `CompoundPathItem.pathItems` reads the paths of a compound path. `crates/engine/src/tests/script_dom.rs`.
|
||||
- Scripts: a document's layers and sublayers with their options, stacking and current layer, its groups and compound paths with clipping masks and new empty groups, and its artboards with their rectangles, names, ruler origins and display options, added, inserted, removed and made active, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Layer/, https://ai-scripting.docsforadobe.dev/jsobjref/Layers/, https://ai-scripting.docsforadobe.dev/jsobjref/GroupItems/, https://ai-scripting.docsforadobe.dev/jsobjref/CompoundPathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/Artboard/ and https://ai-scripting.docsforadobe.dev/jsobjref/Artboards/ describe them (`docs/mcp.md`). Views are not there yet. `crates/engine/src/tests/script_dom.rs`, `crates/ui-egui/src/tests/script_run.rs`.
|
||||
- Scripts: a document's perspective grid is shown, hidden, given its active plane and reset to a built-in or saved preset of the type the script names, and `app.getPresetSettings` gives the settings of a startup preset as a `DocumentPreset`, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Document/ and https://ai-scripting.docsforadobe.dev/jsobjref/Application/ list them (`docs/mcp.md`). Showing, hiding and the active plane add no undo step in a script run, as outside one. Workspaces, `loadColorSettings`, `showPresets` and perspective grid preset files are not there yet. `crates/engine/src/tests/script_dom_perspective.rs`.
|
||||
- Scripts: Window › Script Console shows each run's `$.write` and `$.writeln` output, `vc.log` entries, uncaught error with the script's name, line and column, and a report of its time, host calls and slowest commands, keeping at most 2,048 lines and counting the lines it dropped. `script.run`'s report carries the same data, and `script.console`, `script.console.clear` and `ui.copyScriptConsole` read, clear and copy it. `crates/engine/src/tests/script_console.rs`.
|
||||
- Scripts: the status bar translates its own words around a failed run's error and the app's own error messages, and shows text the script threw itself (a value, an error it made, or an error whose name or message it changed) as it is, even when that text reads like one of the app's messages. `script.run`'s report gives `messageOrigin` (`script` or `built-in`), and the advice about objects other applications give their scripts follows only the app's own reference errors. VectorCraft's own rule. `crates/js/src/interp_tests.rs`, `crates/engine/src/tests/script_run.rs`, `crates/ui-egui/src/chrome/tests.rs`.
|
||||
- Scripts: the `$` object has the other members the Dollar object page lists (https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/), from `$.about()` to `$.version`, and scripts have the global `localize(object, ...values)` (https://extendscript.docsforadobe.dev/extendscript-tools-features/localizing-extendscript-strings/), `toSource(value)` and `Object.prototype.toSource()`. Each run starts with the interface's locale, and what a script changes in `$` lasts only for that run. `crates/engine/src/tests/script_dollar.rs`, `crates/js/src/extension_tests.rs`.
|
||||
|
||||
Reference in new issue
Block a user