Skip to main content

Module scripting

Module scripting 

Source
Expand description

Scripts in the CAD app: the CAD host for the PLM’s interpreter core (S11). Scripts in the CAD app: the CAD-side host for the interpreter the PLM’s administrator hooks run on (BREP_script_core, plm-cad-integration-todo §3 S11).

The core evaluates one file and calls one global function with one JSON argument; this module decides what a script running inside the CAD app can reach. Today that is:

GlobalWhat it is
console.log / info / warn / errorlines kept with the outcome (the core’s own binding)
cad.versionthis app’s version
cad.store"file" natively, "browser" in the wasm build
cad.plmfalse: no PLM is connected
ui.notify(text)a message for the user, kept with the outcome for the host to show

There are NO plm.* bindings yet. They arrive with the PLM transport (S1), and every one of them will need a signed-in session; PLM_BINDINGS names them so a script can be told which of its calls need a server. Until then a script that reaches for plm finds it undefined, which is also exactly what it finds with no server connected — the file-only case is the only case, and it runs the same natively and in the browser.

Structs§

Failure
A call that threw, failed to parse, or named a function the file does not define. message is what a person reads: for throw new Error("x") it is x, for throw "x" it is x.
Outcome
A finished call: the core’s result plus what the script asked the UI to show.
Success
A call that returned.

Constants§

PLM_BINDINGS
The plm.* bindings a CAD script can call, each needing a connected PLM. Empty until S1 lands the transport.

Functions§

call
Evaluate source (named file in messages) with the CAD host installed, then call its global function with input.
store_kind
Where the app keeps its documents, as cad.store reports it.