Group an edit into a named transaction, undo and redo it, then save the document, close it, open it again, and read the values back.
Generated page.tools/userdocs.py writes it from
tools/workflows/03_undo_and_persistence.py.
Edit the workflow, not this page; python3 tools/userdocs.py --check
fails when the two disagree.
Requires: the FreeCAD facade; a writable temporary directory.
Everything between openTransaction and commitTransaction is one undoable step. A workbench wraps each command in exactly this, which is why undo never lands in the middle of a command.
saveAs writes the document format; open reads it into a new document with the same names and property values. The path is a temporary file, so it is not shown.
import os
path = os.path.join(tempfile.mkdtemp(prefix="ferrocad-userdocs-"), "undoable.ferrocad")
doc.saveAs(path)
doc_name = doc.Name