Grid.Space
Search…
API, CLI, Embedding
Various ways to access Kiri:Moto's internals (2.6 and newer versions only)

Javascript Slicer Engine

The latest slicing engine code is served live at https://grid.space/code/engine.js
This can be embedded in your page then accessed with the following API calls. An example page is here.
function
description
load(url)
load an STL referred to by url
clear()
remove all objects from workspace
parse(data)
parse the text or binary contents of an STL file
setMode(mode)
where mode comes from:[ "CAM", "FDM", "LASER", "SLA" ]
setListener(fn)
a function to receive engine progress messages
setDevice(options)
change default Device options
setProcess(options)
change default Process options
setController(options)
change default Core options
moveTo(x, y, z)
absolute move the origin of the loaded object
move(x, y, z)
relative move the origin of the loaded object
scale(x, y, z)
scale axes of the loaded object
rotate(x, y, z)
relative rotate axes of loaded object (in radians)
slice()
async slice of loaded object
prepare()
async path routing of slice data
export()
async gcode generation from routed paths

Command Line API

The slicer engine is also available as a command-line utility
1
node src/kiri-run/cli --help
2
3
cli <options> <file>
4
--verbose | enable verbose logging
5
--dir=[dir] | root directory for file paths (default: '.')
6
--model=[file] | model file to load (or last parameter)
7
--source=[file] | source file list (defaults to kiri engine)
8
--device=[file] | device definition file (json)
9
--process=[file] | process definition file (json)
10
--controller=[file] | controller definition file (json)
11
--output=[file] | gcode output to file or '-' for stdout
12
--position=x,y,z | move loaded model to position x,y,z
13
--rotate=x,y,z | rotate loaded model x,y,z radians
14
--scale=x,y,z | scale loaded model in x,y,z
15
--move=x,y,z | move loaded model x,y,z millimeters
Copied!
Example Device and Process settings which are defined in init.js around line 250
JSON dictionaries can be used for reference from the CLI package

Embedding Kiri:Moto with an IFrame

Kiri:Moto is designed to be embedded in a page using an IFrame. The look and feel and other controls are available for the loaded page using a messaging API. An example page is here.
function
description
setFrame(id_obj)
id or object of IFrame with Kiri:Moto loaded
load(url)
load an STL referred to by url
clear()
remove all objects from workspace
parse(data)
parse the text or binary contents of an STL file
setMode(mode)
where mode comes from:[ "CAM", "FDM", "LASER", "SLA" ]
setDevice(options)
change default Device options
setProcess(options)
change default Process options
setController(options)
change default Core options
slice()
async slice of loaded object
prepare()
async path routing of slice data
export()
async gcode generation from routed paths
onmessage(fn)
function will receive all IFrame messages
onevent(event, data)
function will receive named messages
emit(event, data)
send named event with data payload
alert(msg, time)
show alert message with optional time in seconds
process(percent, message)
set progress bar (0.0 to 1.0) with optional message

Events

Key
Output
Description
animate
CNC Animation Started
boolean.update
Boolean checkbox values sync'd
code.load
GCode or SVG code is being loaded / parsed
code.loaded
GCode / SVG code parsing complete
device.set
A new machine / device was selected
export
GCode / SVG export dialog is open
help.show
A Help dialog is open
init-done
App is fully initialized
init.one
App is starting to initialize
init.two
App is binding UI elements
key.esc
[ESC] key was pressed
keypress
A non-control or meta key was pressed
load.lib
A script extension was loaded
modal.show
A modal dialog is showing
mode.set
App mode changed: FDM, CNC, Laser, SLA
mouse.hover
Mouse is hovering over a feature of interest
mouse.hover.down
Mouse down on a feature of interest
mouse.hover.up
Mouse up on a feature of interest
platform.layout
Platform auto-layout was performed