lmcad reference
Command-line flags, exit codes, host types, methods, functions, limits and standard-library signatures of lmcad 0.1.5, generated from the release binary (lmcad --lmcode-schema and lmcad --lmcode-signatures) and the repository README. Types in signatures are int, float, string, bool and the host or standard types named here.
Command line
| Command | Effect |
|---|---|
| lmcad --version | Prints lmcad X.Y.Z. The release tag vX.Y.Z and the binary version must agree for install="github:lmctl-ai/lmcad@latest". |
| lmcad --lmcode-schema | Prints a compact summary: the context line, then free functions, then members grouped by type. |
| lmcad --lmcode-schema --json | Prints the embedded schema bytes exactly (dsl.schema 2, name lmcad). This is the compiler input. |
| lmcad --lmcode-signatures | Prints the canonical signature list of the host registry, host and standard: 271 lines in 0.1.5. |
| lmcad --lmcode FILE [FILE ...] | Runs compiled program files in argument order. Objects and scene state persist between files; locals are fresh for each file. The first failure stops execution. |
With no arguments or an unknown flag the host prints its usage line and exits 2. Failures also print a JSON result between the lines LMCODE_RETURN_BEGIN and LMCODE_RETURN_END.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success; one JSON result line per completed block. |
| 2 | Invalid command line. The host prints its usage line and a CLI_USAGE result (phase cli). |
| 3 | Program file load failure or a block or host run failure. |
| 4 | Another application failure. |
Used from lmscript
| Form | Meaning |
|---|---|
| p = _lmcode_ cli="lmcad" install="github:lmctl-ai/lmcad@latest"; ... end _lmcode_ | Declares a block compiled against the schema the lmcad binary reports. install lets lmscript download the released binary when needed. |
| r = run_lmcode(p) | Runs the block on the host and returns a result with ok and result; the repository examples print r.stderr and r.stdout on failure. |
| lmscript --check FILE.lms | Compiles every block against the host schema without running it. |
| lmctl autorun URL | Downloads and runs an example .lms, fetching the released lmcad. |
Context and host types
| Name | Kind | Role |
|---|---|---|
| scene | Context object of type Scene | The one entry point of a block. |
| Scene | Host type | Solids, sketches, lights, cameras, renders, exports and assertions. |
| Shape | Host type | Handle to an OpenCASCADE solid: transforms, booleans, edge treatment, volume and bounds. |
| Sketch | Host type | Straight-segment 2D polygon to extrude or revolve. |
| Material | Host type | Display color and Blinn-Phong surface parameters. |
| Camera | Host type | View returned by camera and fit_camera. |
| Light | Host type | Directional or fill light. |
| Animation | Host type | APNG writer. |
| Keyframes | Host type | Collection read from CSV; supports len, at and for-in iteration. |
| Keyframe | Host type | One CSV row: time, position and color. |
The schema declares no enum types.
Host functions
| Signature | Returns | Description |
|---|---|---|
| material() | Material | Creates a material; chain color, roughness, specular and shininess. |
| read_keyframes_csv(string) | Keyframes | Reads keyframes from a CSV file path. |
Scene methods
| Signature | Returns | Description |
|---|---|---|
| Scene.ambient(float) | Scene | Sets the ambient light level; returns the scene for chaining. |
| Scene.animation(string, int, int, int) | Animation | Opens an APNG writer: path, width, height, frames per second (integer 1 to 240). |
| Scene.assert_close(float, float, float) | void | Fails the run unless actual and expected agree within the tolerance: actual, expected, tolerance. |
| Scene.background(float, float, float) | Scene | Sets the background color from red, green, blue components. |
| Scene.box(float, float, float, Material) | Shape | Box solid from three dimensions and a material. |
| Scene.camera(float, float, float, float, float, float, float) | Camera | Creates an explicit camera from seven numbers (field of view, then position and target coordinates as used in the tutorial). |
| Scene.cylinder(float, float, Material) | Shape | Cylinder solid from radius, height and a material. |
| Scene.directional_light(float, float, float, float) | Light | Adds a directional light: direction x, y, z and intensity. |
| Scene.export_obj(string) | void | Writes the scene mesh as text OBJ to the path. |
| Scene.export_stl(string) | void | Writes the scene mesh as binary STL to the path. |
| Scene.extrude(Sketch, float, Material) | Shape | Extrudes a closed sketch by a height into a solid. |
| Scene.fill_light(float, float, float, float) | Light | Adds a fill light: direction x, y, z and intensity. |
| Scene.fit_camera(float, float) | Camera | Fits the camera to the scene: field of view and margin. Explicit look_at or clipping settings turn off automatic fitting. |
| Scene.render_png(string, int, int) | void | Renders the scene to a PNG: path, width, height. |
| Scene.render_ppm(string, int, int) | void | Renders the scene to an RGB PPM: path, width, height. |
| Scene.revolve_y(Sketch, Material) | Shape | Revolves a closed sketch around the y axis into a solid. |
| Scene.sketch() | Sketch | Starts an empty 2D sketch. |
| Scene.sphere(float, Material) | Shape | Sphere solid from radius and a material. |
| Scene.supersample(int) | Scene | Sets n by n supersampling, n from 1 to 8; output dimensions stay unchanged. |
| Scene.tube_between(float, float, float, float, float, float, float, Material) | Shape | Solid cylindrical segment between two 3D endpoints: x1, y1, z1, x2, y2, z2, radius, material. |
Shape methods
| Signature | Returns | Description |
|---|---|---|
| Shape.chamfer(float) | Shape | Chamfers the edges by a distance. |
| Shape.color(float, float, float) | Shape | Sets the display color from red, green, blue. |
| Shape.cut(Shape) | Shape | Boolean difference: removes the argument shape. |
| Shape.fillet(float) | Shape | Rounds the edges by a radius. |
| Shape.hollow(float) | Shape | Shells the solid to a wall thickness. |
| Shape.hollow_top(float) | Shape | Shells the solid to a wall thickness, leaving the top open. |
| Shape.intersect(Shape) | Shape | Boolean intersection with the argument shape. |
| Shape.max_x() | float | Bounding-box maximum x. |
| Shape.max_y() | float | Bounding-box maximum y. |
| Shape.max_z() | float | Bounding-box maximum z. |
| Shape.min_x() | float | Bounding-box minimum x. |
| Shape.min_y() | float | Bounding-box minimum y. |
| Shape.min_z() | float | Bounding-box minimum z. |
| Shape.mirror(string) | Shape | Mirrors the shape; the string selects the mirror plane or axis. |
| Shape.name(string) | Shape | Names the shape. |
| Shape.position(float, float, float) | Shape | Places the shape at x, y, z. |
| Shape.rotate(float, float, float) | Shape | Rotates the shape by three angles. |
| Shape.scale(float, float, float) | Shape | Scales the shape by x, y, z factors. |
| Shape.translate(float, float, float) | Shape | Moves the shape by dx, dy, dz. |
| Shape.union(Shape) | Shape | Boolean union with the argument shape. |
| Shape.visible(bool) | Shape | Shows or hides the shape in renders. |
| Shape.volume() | float | B-rep volume of the solid. |
Sketch methods
| Signature | Returns | Description |
|---|---|---|
| Sketch.close() | Sketch | Closes the polygon. |
| Sketch.point(float, float) | Sketch | Appends a vertex x, y; segments are straight. |
Material methods
| Signature | Returns | Description |
|---|---|---|
| Material.color(float, float, float) | Material | Sets red, green, blue. |
| Material.roughness(float) | Material | Sets roughness. |
| Material.shininess(float) | Material | Sets Blinn-Phong shininess. |
| Material.specular(float) | Material | Sets specular strength. |
Camera methods
| Signature | Returns | Description |
|---|---|---|
| Camera.clipping(float, float) | Camera | Sets near and far clipping distances. |
| Camera.look_at(float, float, float, float, float, float) | Camera | Sets eye position and target from six coordinates. |
Light methods
| Signature | Returns | Description |
|---|---|---|
| Light.intensity(float) | Light | Sets the light intensity. |
Animation methods
| Signature | Returns | Description |
|---|---|---|
| Animation.add_frame() | Animation | Renders the current scene as the next frame. |
| Animation.finish() | void | Finishes the file and atomically replaces the destination; an unfinished animation is discarded. |
Keyframes methods
| Signature | Returns | Description |
|---|---|---|
| Keyframes.at(int) | Keyframe | Keyframe at a zero-based index. |
| Keyframes.len() | int | Number of keyframes. |
Keyframe methods
| Signature | Returns | Description |
|---|---|---|
| Keyframe.b() | float | Blue color component. |
| Keyframe.g() | float | Green color component. |
| Keyframe.r() | float | Red color component. |
| Keyframe.time() | float | Time value of the keyframe. |
| Keyframe.x() | float | Position x. |
| Keyframe.y() | float | Position y. |
| Keyframe.z() | float | Position z. |
Host limits
| Item | Limit |
|---|---|
| Sketch coordinates | within ±500 units |
| Part extent | 1000 units |
| Faces per shape | 2000 |
| Edges per shape | 10,000 |
| Triangles | 1,000,000 |
| Supersampling | 1 to 8; each raster dimension times n at most 8192 |
| Pixels per frame | 16,777,216 |
| Animation frames | 240 |
| Total animation frame pixels | 64,000,000 |
| Animation frame rate | integer 1 through 240 |
Output formats
| Format | Produced by | Notes |
|---|---|---|
| PNG | Scene.render_png | Still images; deterministic encoding. |
| PPM | Scene.render_ppm | Simple RGB raster. |
| APNG | Scene.animation, Animation.add_frame, Animation.finish | Loops forever with exact rational frame delays. |
| STL | Scene.export_stl | Binary triangle mesh; write-only. |
| OBJ | Scene.export_obj | Text mesh; write-only. |
Standard library
lmcad 0.1.5 ships 206 standard-library signatures (the lmcode_std_v3 catalog at 206). The current lmcode_std_v3 catalog has 226 signatures, adding the REST and CLI interfaces; lmcad picks those up when it syncs and releases, and the 0.1.5 binary does not register them.
Standard functions
| Group | Signature | Returns |
|---|---|---|
| Collections | float_list() | FloatList |
| Collections | float_map() | FloatMap |
| Collections | float_pq() | FloatPQ |
| Collections | float_queue() | FloatQueue |
| Collections | float_stack() | FloatStack |
| Collections | int_list() | IntList |
| Collections | int_map() | IntMap |
| Collections | int_pq() | IntPQ |
| Collections | int_queue() | IntQueue |
| Collections | int_stack() | IntStack |
| Collections | str_list() | StrList |
| Collections | str_map() | StrMap |
| Collections | str_pq() | StrPQ |
| Collections | str_queue() | StrQueue |
| Collections | str_stack() | StrStack |
| Files | file_append(string, string) | void |
| Files | file_exists(string) | bool |
| Files | file_lines(string) | StrList |
| Files | file_read(string) | string |
| Files | file_write(string, string) | void |
| JSON and templates | json_parse(string) | Json |
| JSON and templates | template_render(string, Json) | string |
| Math | math_abs(float) | float |
| Math | math_abs(int) | int |
| Math | math_ceil(float) | float |
| Math | math_ceil(int) | int |
| Math | math_floor(float) | float |
| Math | math_floor(int) | int |
| Math | math_max(float, float) | float |
| Math | math_max(int, int) | int |
| Math | math_min(float, float) | float |
| Math | math_min(int, int) | int |
| Math | math_pow(float, float) | float |
| Math | math_pow(int, int) | int |
| Math | math_round(float) | float |
| Math | math_round(int) | int |
| Math | math_sqrt(float) | float |
| Math | math_sqrt(int) | int |
| Return values | lmcode_return_null() | void |
| Return values | lmcode_return_put(string, FloatList) | void |
| Return values | lmcode_return_put(string, FloatMap) | void |
| Return values | lmcode_return_put(string, IntList) | void |
| Return values | lmcode_return_put(string, IntMap) | void |
| Return values | lmcode_return_put(string, Json) | void |
| Return values | lmcode_return_put(string, StrList) | void |
| Return values | lmcode_return_put(string, StrMap) | void |
| Return values | lmcode_return_put(string, bool) | void |
| Return values | lmcode_return_put(string, float) | void |
| Return values | lmcode_return_put(string, int) | void |
| Return values | lmcode_return_put(string, string) | void |
| Return values | lmcode_return_put_null(string) | void |
| Return values | lmcode_return_set(FloatList) | void |
| Return values | lmcode_return_set(FloatMap) | void |
| Return values | lmcode_return_set(IntList) | void |
| Return values | lmcode_return_set(IntMap) | void |
| Return values | lmcode_return_set(Json) | void |
| Return values | lmcode_return_set(StrList) | void |
| Return values | lmcode_return_set(StrMap) | void |
| Return values | lmcode_return_set(bool) | void |
| Return values | lmcode_return_set(float) | void |
| Return values | lmcode_return_set(int) | void |
| Return values | lmcode_return_set(string) | void |
| Strings | str_base64_decode(string) | string |
| Strings | str_base64_encode(string) | string |
| Strings | str_contains(string, string) | bool |
| Strings | str_ends_with(string, string) | bool |
| Strings | str_find(string, string) | int |
| Strings | str_hex_decode(string) | string |
| Strings | str_hex_encode(string) | string |
| Strings | str_is_float(string) | bool |
| Strings | str_is_int(string) | bool |
| Strings | str_len(string) | int |
| Strings | str_lower(string) | string |
| Strings | str_match(string, string) | bool |
| Strings | str_repeat(string, int) | string |
| Strings | str_replace(string, string, string) | string |
| Strings | str_split(string, string) | StrList |
| Strings | str_starts_with(string, string) | bool |
| Strings | str_substr(string, int, int) | string |
| Strings | str_to_float(string) | float |
| Strings | str_to_int(string) | int |
| Strings | str_trim(string) | string |
| Strings | str_upper(string) | string |
Standard types and methods
| Type | Signature | Returns |
|---|---|---|
| FloatList | FloatList.add(float) | FloatList |
| FloatList | FloatList.at(int) | float |
| FloatList | FloatList.clear() | FloatList |
| FloatList | FloatList.contains(float) | bool |
| FloatList | FloatList.index_of(float) | int |
| FloatList | FloatList.len() | int |
| FloatList | FloatList.set(int, float) | FloatList |
| FloatMap | FloatMap.clear() | FloatMap |
| FloatMap | FloatMap.get(string) | float |
| FloatMap | FloatMap.get_or(string, float) | float |
| FloatMap | FloatMap.has(string) | bool |
| FloatMap | FloatMap.key_at(int) | string |
| FloatMap | FloatMap.keys() | StrList |
| FloatMap | FloatMap.len() | int |
| FloatMap | FloatMap.remove(string) | bool |
| FloatMap | FloatMap.set(string, float) | FloatMap |
| FloatMap | FloatMap.values() | FloatList |
| FloatPQ | FloatPQ.clear() | FloatPQ |
| FloatPQ | FloatPQ.empty() | bool |
| FloatPQ | FloatPQ.len() | int |
| FloatPQ | FloatPQ.peek() | float |
| FloatPQ | FloatPQ.pop() | float |
| FloatPQ | FloatPQ.push(float, float) | FloatPQ |
| FloatQueue | FloatQueue.at(int) | float |
| FloatQueue | FloatQueue.clear() | FloatQueue |
| FloatQueue | FloatQueue.empty() | bool |
| FloatQueue | FloatQueue.len() | int |
| FloatQueue | FloatQueue.peek() | float |
| FloatQueue | FloatQueue.pop() | float |
| FloatQueue | FloatQueue.push(float) | FloatQueue |
| FloatStack | FloatStack.at(int) | float |
| FloatStack | FloatStack.clear() | FloatStack |
| FloatStack | FloatStack.empty() | bool |
| FloatStack | FloatStack.len() | int |
| FloatStack | FloatStack.peek() | float |
| FloatStack | FloatStack.pop() | float |
| FloatStack | FloatStack.push(float) | FloatStack |
| IntList | IntList.add(int) | IntList |
| IntList | IntList.at(int) | int |
| IntList | IntList.clear() | IntList |
| IntList | IntList.contains(int) | bool |
| IntList | IntList.index_of(int) | int |
| IntList | IntList.len() | int |
| IntList | IntList.set(int, int) | IntList |
| IntMap | IntMap.clear() | IntMap |
| IntMap | IntMap.get(string) | int |
| IntMap | IntMap.get_or(string, int) | int |
| IntMap | IntMap.has(string) | bool |
| IntMap | IntMap.key_at(int) | string |
| IntMap | IntMap.keys() | StrList |
| IntMap | IntMap.len() | int |
| IntMap | IntMap.remove(string) | bool |
| IntMap | IntMap.set(string, int) | IntMap |
| IntMap | IntMap.values() | IntList |
| IntPQ | IntPQ.clear() | IntPQ |
| IntPQ | IntPQ.empty() | bool |
| IntPQ | IntPQ.len() | int |
| IntPQ | IntPQ.peek() | int |
| IntPQ | IntPQ.pop() | int |
| IntPQ | IntPQ.push(int, float) | IntPQ |
| IntQueue | IntQueue.at(int) | int |
| IntQueue | IntQueue.clear() | IntQueue |
| IntQueue | IntQueue.empty() | bool |
| IntQueue | IntQueue.len() | int |
| IntQueue | IntQueue.peek() | int |
| IntQueue | IntQueue.pop() | int |
| IntQueue | IntQueue.push(int) | IntQueue |
| IntStack | IntStack.at(int) | int |
| IntStack | IntStack.clear() | IntStack |
| IntStack | IntStack.empty() | bool |
| IntStack | IntStack.len() | int |
| IntStack | IntStack.peek() | int |
| IntStack | IntStack.pop() | int |
| IntStack | IntStack.push(int) | IntStack |
| Json | Json.as_bool() | bool |
| Json | Json.as_float() | float |
| Json | Json.as_int() | int |
| Json | Json.as_string() | string |
| Json | Json.at(int) | Json |
| Json | Json.get(string) | Json |
| Json | Json.has(string) | bool |
| Json | Json.keys() | StrList |
| Json | Json.kind() | string |
| Json | Json.len() | int |
| Json | Json.to_json() | string |
| StrList | StrList.add(string) | StrList |
| StrList | StrList.at(int) | string |
| StrList | StrList.clear() | StrList |
| StrList | StrList.contains(string) | bool |
| StrList | StrList.index_of(string) | int |
| StrList | StrList.join(string) | string |
| StrList | StrList.len() | int |
| StrList | StrList.set(int, string) | StrList |
| StrMap | StrMap.clear() | StrMap |
| StrMap | StrMap.get(string) | string |
| StrMap | StrMap.get_or(string, string) | string |
| StrMap | StrMap.has(string) | bool |
| StrMap | StrMap.key_at(int) | string |
| StrMap | StrMap.keys() | StrList |
| StrMap | StrMap.len() | int |
| StrMap | StrMap.remove(string) | bool |
| StrMap | StrMap.set(string, string) | StrMap |
| StrMap | StrMap.values() | StrList |
| StrPQ | StrPQ.clear() | StrPQ |
| StrPQ | StrPQ.empty() | bool |
| StrPQ | StrPQ.len() | int |
| StrPQ | StrPQ.peek() | string |
| StrPQ | StrPQ.pop() | string |
| StrPQ | StrPQ.push(string, float) | StrPQ |
| StrQueue | StrQueue.at(int) | string |
| StrQueue | StrQueue.clear() | StrQueue |
| StrQueue | StrQueue.empty() | bool |
| StrQueue | StrQueue.len() | int |
| StrQueue | StrQueue.peek() | string |
| StrQueue | StrQueue.pop() | string |
| StrQueue | StrQueue.push(string) | StrQueue |
| StrStack | StrStack.at(int) | string |
| StrStack | StrStack.clear() | StrStack |
| StrStack | StrStack.empty() | bool |
| StrStack | StrStack.len() | int |
| StrStack | StrStack.peek() | string |
| StrStack | StrStack.pop() | string |
| StrStack | StrStack.push(string) | StrStack |
Standard REST and CLI interfaces
These belong to the current 226-signature lmcode_std_v3 catalog. They are not registered by lmcad 0.1.5 (lmcad --lmcode-signatures lists none of them), so blocks for this release cannot call them; the table records what arrives when lmcad syncs to the current catalog.
| Item | Kind | Status in lmcad 0.1.5 |
|---|---|---|
| RestGet | Standard interface | Not available |
| RestPost | Standard interface | Not available |
| RestPut | Standard interface | Not available |
| RestDelete | Standard interface | Not available |
| RestPatch | Standard interface | Not available |
| RestHead | Standard interface | Not available |
| RestOptions | Standard interface | Not available |
| RestHandler | Standard interface | Not available |
| CliCommand | Standard interface | Not available |
| CliOption | Standard interface | Not available |
| rest_config(string, string) -> void | Standard function | Not available |
| rest_route(string, string, string) -> void | Standard function | Not available |
| rest_serve() -> void | Standard function | Not available |
| rest_stop() -> void | Standard function | Not available |
| rest_cli(StrList) -> string | Standard function | Not available |
| RestExchange (15 methods) | Standard type | Not available |