Commit Graph
9 Commits
Author SHA1 Message Date
dotCooCoo f6619ed732 Scripts: closing a path with no points throws
PathItem.closed = true on a path with no points had no subpath to store
the value in, so the assignment reported success while closed still
read false. It now throws "Cannot close a path that has no points".
2026-11-28 03:21:05 -08:00
dotCooCoo 011f477546 Scripts: reordered layers skip unchanged objects; opened paths drop their segments
changed_ids pairs added, removed or reordered siblings by id, so an object
that only moved is skipped and a changed one is compared level by level
instead of listing every descendant of each shifted layer.

A path that was opened or closed during a script keeps its anchor counts
but not its segment indexes, so it is no longer selected again with a
segment that does not exist (select.segments refused it after the
change was applied).

docs/mcp.md states that a hidden or locked Live Paint group throws the
hidden-or-locked error rather than the Live Paint one.
2026-11-28 02:54:05 -08:00
dotCooCoo 637facb057 Scripts: empty objects read zero control bounds and turn or scale as no-ops
- controlBounds of an object with nothing in it reads zeros, like its
  geometric and visible bounds.
- path.rotate and path.resize of a path with no anchors change nothing.
- The path tests make the first rectangle last, so pathItems[0] is the
  topmost path as pageItems lists it.
2026-11-26 00:27:19 -08:00
dotCooCoo a8cd6180ce Scripts: fix further review findings in the layer and path items
- Point changes that add, remove or replace points deselect the path's
  direct-selected anchors even when the counts come out the same;
  path.setAnchors takes `reshaped` for this and refuses a non-boolean.
- Moving points or handles, changing a point's type or setting `closed`
  keeps the index of where each subpath's points start.
- A failed write keeps the waiting point changes.
- Restoring the selection keeps a segment-only path to its segments.
- getIsFileOpen folds `\` and letter case only on Windows.
- Assigning `undefined` to Document.selection throws with nothing changed.
- A document's path list is charged for the objects it looks at.
- A made path keeps an id above 2^53.
- A host object's handle is charged to the heap limit.
- docs/mcp.md states that node.move into a compound path also needs its
  layer and groups shown and unlocked and no locked artboard.
2026-11-25 20:47:22 -08:00
dotCooCoo 80c33ec810 Scripts: fix review findings in the layer and path items
- controlBounds takes in the paths' direction handles. A clipping
  group's are its clipping path's.
- A compound path's pathItems is a PathItems collection: add() and the
  shape methods make the path inside it.
- resize() scales and sets the stroke weight as one step, so a failed
  stroke change undoes the scale too.
- A point change that adds or removes anchors deselects the path's
  direct-selected anchors, from a script and from path.setAnchors, so
  other anchors are not left selected in their place.
- A script that ends past the allowance of the last answer is asked
  again before its changes are kept.
- documents.addDocument starts from the built-in preset when a saved
  preset has its name, and Recent keeps the built-in preset's name.
- Saved preset rows past the artboard limit read as the limit.
- Host classes that do not fit the heap end with the heap limit.
- Layers keep their list while the document is unchanged, and getByName
  charges its scan on a kept list too.
- Selection ids are deduplicated with a set.
- A path made on the current layer is made in one step, so a failed
  stroke or reversal after it undoes the path too.
- Path points are found through a kept index of where each subpath's
  points start, rebuilt when the path's points change, so reading every
  point of a path with many subpaths is no longer quadratic.
- A pixel-aligned compound path snaps a path moved into it.
2026-11-25 04:38:31 -08:00
dotCooCoo bd945697e8 Scripts: a path point read before a command changes its path is stale
A PathPoint read before vc.run('path.setAnchors', ...) replaced its
path's points stayed valid, so a later write changed the replacement's
point at the same index. The object model now keeps each path whose
points the script read and checks it after every command and when a
point is used. When the path's points differ from the ones it last saw,
or the path is gone, the points read before throw `Stale path point`.
This covers any command run with vc.run, an undo, and a change that a
later command reverses. Points stay valid through the object model's
own changes to the path or to an object that holds it, such as
translate().

docs/mcp.md and the module doc state the rule.
2026-11-21 18:06:28 -08:00
dotCooCoo 07d673898f Scripts: a path point read before its path's points are removed is stale
A PathPoint kept its index, so after `remove()` of an earlier point it
read and changed the point that moved into its place. A point read
before the script removed a point of its path (`remove()`,
`removeAll()`) or replaced its points (`setEntirePath`) now throws
`Stale path point`.
2026-11-21 15:14:52 -08:00
dotCooCoo 55f615d0c9 Scripts: write path point edits with one command, keep colors exact
- Changes to a path's points (closed, setEntirePath, pathPoints and each
  PathPoint) wait in the object model and are written by one
  path.setAnchors before any other member or command, before another
  path's points change, and when the script ends. A loop over 2,000
  points now runs one command and makes one undo step. A path aligned to
  the pixel grid is written at each change so its points read snapped.
- A color component reads with the fewest decimals, at least 4, that give
  the stored value back, so assigning a color read from a path leaves the
  path unchanged (RGB, CMYK, Gray and Lab, fill and stroke).
- add() and the shape creators put the new path on top of the active
  layer whatever the drawing mode, and leave the mode as it was.
- fillOverprint and strokeOverprint change the top fill or stroke only.
- filled = true on a compound path member places the new-art gradient on
  the compound path's bounds.
- An identity rotate or resize checks its arguments and runs no command,
  on an empty path too.
- Tests for each of these, and for setAnchors reading smooth false as a
  corner.

Docs: docs/mcp.md, docs/gaps.md, docs/roadmap.md,
docs/target-app-parity.md.
2026-11-21 13:32:25 -08:00
dotCooCoo 43813db855 Scripts: paths, path points and colors for scripts
Document.pathItems lists a document's paths and makes empty paths,
rectangles, rounded rectangles, ellipses, polygons and stars with the
parameter order and defaults of the PathItems help page. A PathItem
reads and changes its points, closed state, fill rule, area, length,
fill and stroke colors, stroke options and overprint, and translates,
rotates and resizes. PathPoints and PathPoint read and set each
point's anchor, handles and type. RGBColor, CMYKColor, GrayColor,
LabColor and NoColor make colors; a gradient, spot or pattern paint
reads as GradientColor, SpotColor or PatternColor.

Each change runs an existing command (path.create, the shape.*
commands, path.setAnchors, path.close, path.setFillRule,
paint.setFill, paint.setStroke, stroke.set, object.setOverprint,
object.move, object.rotate, object.scale) inside the run's one undo
step, and puts back the selection and the paint for new art. A value
that changes nothing runs no command; a bad value throws and changes
nothing.

path.setAnchors now makes an anchor a corner when it is given
`smooth: false`; before, the key was ignored and handles in line made
it smooth.
2026-11-21 11:03:42 -08:00