Anvil
Anvil is the shared runtime toolkit for CATIA Magic resource development. It supplies profile bindings, auto-stereotyping, model-event tracing, logging, model-value rendering, query operations, notifications, diagram image export and guarded element creation. Anvil is built and published as a CATIA Magic Resource carrying a Plugin by the Forge Gradle plugin.
Who it is for
Anvil serves engineers who write CATIA Magic resources and plugins in Kotlin and want the plumbing every resource needs without rewriting it.
Where to start
A new consumer begins with Anvil: declare the dependency,
which adds Anvil to a resource's build. The sidebar then groups the pages by what the reader is doing.
How-to pages open with Anvil: when they teach an Anvil facility and Open API: when they teach the
tool's own API for the same subject, so a reader weighing the dependency can see both.
What Anvil carries
Eleven packages, each running inside CATIA Magic and called by a plugin author directly.
| Package | Carries |
|---|---|
profile.runtime | The typed profile-binding API (ProfileReference, StereotypeReference, the tag references, EnumerationReference) that hand-written and generated bindings both sit on |
autostereotype | The auto-stereotyping engine and the rule contract a resource extends |
events | The model-event tracer, standalone of the engine: a plugin with no rules traces a project's commits with ModelEventTrace alone |
logging | ResourceLog.of(category), which writes into CATIA Magic's own Log4j log under a category of the resource's own |
format | fString and hString, which render any value, model element or not, as text a reader can act on |
query | Query operations a plugin calls directly and a modeller composes in the expression editor, bound from Anvil_Queries.mdzip |
notification | Notify.of(category), which shows a modeller a balloon in the lower-right corner and records the same message in the log |
diagramimage | DiagramImage, which exports a diagram as an image, and the shortcut-menu entries a modeller fires it from |
model | ElementFactory, which creates an element with its name, owner and stereotype in one call guarded against the metamodel, the platform's permissions and the loaded customizations, and which places a relationship where the tool would when the caller names no owner |
session | Project.commit, which runs a model change in one named session, closed when the change returns and cancelled when it throws |
macro | The macro interpreter (MacroCompiler, MacroRunner and their RunOutcome), the macro shortcut menu built from the Macro menu root project option, and the step functions behind Anvil_Macros_Steps.mdzip; three auto-stereotype rules keep a drawn menu stereotyped, and a commit listener converts a dropped step's value pins |
Everything above is a library a resource calls; Main is the exception. Its init installs the
diagram image export, the macro menu and Anvil's own auto-stereotype engine, the three features Anvil
ships to a modeller directly, and close removes them.
Key concepts
Anvil ships one profile, Anvil Macros Profile, with its customization, and two model libraries.
Anvil_Queries.mdzip holds the query-operation bindings a modeller reaches from the expression
editor, and Anvil_Macros_Steps.mdzip holds the steps a macro calls. The templates and samples folders
carry placeholders alone. What Anvil ships beyond those is the runtime surface every other resource
calls.
The CATIA Magic Developer Guide and Open API digest belong to the catia-magic-ai-docs repository,
which installs them for agents at dev-env/ai-docs/. The Gradle plugin that builds Anvil, including
the Resource and Plugin build and the publishing model, has its own documentation at
https://www.mbseconsulting.com/docs/forge/latest/.