OpenSite/Reference/Commands/Set a quantity

From BathAfrica Documentation
Revision as of 13:59, 29 October 2026 by BathAfrica (talk | contribs) (Reorganize OpenSite help: learning paths, examples and chapter navigation)
Jump to navigation Jump to search
OpenSite 0.0.1 · DevelopmentSource scope and availability


Change one quantity through opensite.document.set_quantity, recompute, and save.

Stable identifier
cli.document.set

Implementation milestone

Roadmap phase 1 (historical Phase 1).

Units

The command interprets --value in --unit and stores the canonical SI quantity. The unit id must already be registered.

Terminal example

opensite-cli document set section.osdoc --property width --value 0.25 --unit m

Python access

examples/python/document_edit.py calls document.set_quantity with a QuantityArgument built from parse_quantity('250 mm').

Output

Stdout is the inspected document after the save. Width 0.25 m and height 0.60 m give area 0.15 m².

Errors

A --value or --object that does not consume the whole argument exits 2 and reports that an argument is not a valid number. That includes a trailing suffix, a negative or out-of-range object id, and a non-finite quantity such as inf or nan. Decimal and scientific forms such as 4e-1 are accepted. The decimal mark is .. The check does not use the machine locale. Exit 2 does not modify the file. A missing required flag exits 2. A rejected edit exits 1 with the status message. An allocation or execution failure exits 1 with its own message.

Limitations

If the file has exactly one object, --object may be omitted. An object id is an integer from 1 through 9007199254740991. Derived properties cannot be edited. This does not switch the unit-preference profile.

Verification evidence

Repository evidence references (not rerun for this publication): CTest cli.document, including --value abc, 0.25m, inf, a negative object id, an oversized object id, an unchanged file after those rejections, and --value 4e-1.


Try this workflow

Quantities and profiles — a worked lesson with expected results.

Documentation basis

Source-reviewed against development commit 77c3fee13944bcc4b5d487c77eb1f82fbe4c6ea7, branch feature/phase-13c-properties-python-expressions. This review inspected the implementation and repository evidence; it did not run the Windows application or repeat CTest.

  • src/cli/main.cpp
  • src/cli/document_commands.cpp
  • src/cli/preference_commands.cpp
  • src/application/builtins.cpp

OpenSite overview · Reference · Guides