2 Saving and recovery
James edited this page 2026-11-12 14:23:17 -05:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Saving and recovery

Saving and opening

Action How
Save Ctrl+S, or File → Save. The first time, Anvil asks where.
Save under another name File → Save As...
Open Ctrl+O, or File → Open...
New document Ctrl+N, or File → New
Open from a terminal anvil part.anvil

The document's name is at the right of the menu bar. A * after it means there are unsaved changes.

Anvil holds one document at a time. With unsaved changes:

  • New and Open ask Discard changes?. Discard Changes goes ahead; Cancel or Esc keeps the document as it is, so you can save first.
  • Closing the window, Ctrl+Q and File → Quit open Unsaved changes, which asks Save changes to bracket.anvil before closing? (the file's name, or this document) and offers Save and Close, Close Without Saving and Cancel.

Ctrl+S and File → Save do the same thing, and refresh the file's thumbnail each time.

The .anvil file

An .anvil file is an ordinary ZIP archive whose entries are stored uncompressed. That costs a few kilobytes and means the file can be searched and compared with ordinary tools.

Entry Contents
document.json Parameters, the feature tree, sketches and their constraints, print settings, named views.
metadata.json The Anvil and kernel versions, the format version, units and timestamps.
thumbnail.png A 256 × 256 picture of the model, for file managers.

What is saved is the recipe, not the result: every feature with its expressions exactly as you typed them. Opening a file rebuilds the model from the recipe. wall * 2 + 0.4 is stored as that text, never as 3.6.

Three things are embedded in full, so the document does not depend on the original file staying where it was: the picture of a canvas, the geometry of a body imported from STEP, and every reference mesh.

What is not saved

The roll-back marker's position, the camera, the selection and the undo history. A document always opens rolled to the end.

Looking inside a file

anvil --inspect bracket.anvil

prints document.json and exits. It reads the entry straight out of the archive without building the model, so it works even on a file this version of Anvil cannot fully open. With jq:

anvil --inspect bracket.anvil | jq .parameters

Because nothing is compressed, plain grep works too:

grep -a wall_thickness bracket.anvil

Inside the app, Document JSON on the UTILITIES tab (also under Help) shows exactly what would be written to document.json for the document as it was when the window opened. Click Refresh to bring it up to date after a change.

Versions

Every file records its format version. An older file is brought up to date as it is loaded and is a current file the next time you save. A file from a newer version of Anvil is refused, with a message naming both versions, because guessing at fields this version does not understand would lose your work on the next save.

If a file is damaged, nothing is loaded and the document you had open is left alone.

Autosave and crash recovery

While a document has unsaved changes, Anvil writes a snapshot of it every three minutes to

~/.local/state/anvil/recovery/

(or $XDG_STATE_HOME/anvil/recovery/ if that variable is set). The snapshot is deleted when you save and when Anvil exits normally. Autosave never overwrites your own file.

If Anvil did not close cleanly (a crash, a power cut, a killed session), the snapshot is still there the next time you start it, and a Recover unsaved work window lists what was found, each with the document's name and the time it was autosaved.

Button Result
Restore Opens the snapshot under the document's original name and marks it modified. Save it to keep it.
Discard Deletes the snapshot.
Later Leaves the snapshots where they are. You will be asked again next time.

Snapshots are ordinary .anvil files named anvil- followed by a process number, so you can open one directly. The snapshot of another copy of Anvil that is still running is left alone.