Declare features and params
A plugin's manifest, moket-plugin.json, says what the plugin adds: its features, the params each one takes, its workbench and its exports. Moket reads it without running the plugin's code. From the params it makes the feature's dialog, checks the values people and agents give, and knows what each feature depends on and what it makes.
Access: moket-plugin.json in your plugin's folder. See Write a plugin.
The manifest
json
{
"id": "com.example.rounded-box",
"name": "Rounded box",
"version": "1.0.0",
"sdk": 1,
"author": "Moket",
"main": "plugin.js",
"features": [
{
"type": "com.example.rounded-box.box",
"version": 1,
"label": "Rounded box",
"params": {
"body": { "kind": "newBody" },
"width": { "kind": "length", "default": "60 mm", "check": "positive" }
}
}
],
"workbench": { "label": "Boxes", "tools": ["com.example.rounded-box.box"] },
"exports": [
{
"id": "footprint",
"label": "Export footprint",
"formats": ["pdf", "svg", "dxf"]
}
]
}| Field | What it is |
|---|---|
id | A reverse domain of your own, such as com.yourname.tools. Ids that start with io.moket. are Moket's |
name | The plugin's name in Settings, the workbench picker and the banner of parts that use it |
version | 1.0.0 style. Raise it when you change the plugin |
sdk | The SDK it is written for: 1 |
author | Optional, shown when someone installs the plugin |
description | Optional, shown when someone installs the plugin |
homepage | Optional, an https address |
main | The module next to the manifest, plugin.js by default |
features | Up to 100 features |
workbench | Optional: its label in the workbench picker and its tools, feature types of this plugin in toolbar order |
exports | Optional: up to 20 exports, each an id, a label for its button and the formats it offers. See Export from a plugin |
Features
| Field | What it is |
|---|---|
type | The plugin's id, a dot and a name: com.example.rounded-box.box. Parts store features by type |
version | The version of its params, from 1. Raise it when you rename or remove a param |
label | Its name on the toolbar and in the history; new features are named after it (Rounded box1) |
description | Optional, one sentence. Agents read it to choose the feature |
icon | Optional, SVG path data on a 24 x 24 grid, drawn as a line |
params | Up to 40 params by name. A name starts with a lower case letter: width, endGap |
When a part has a feature of an older version, Moket keeps the params the feature still declares and gives new ones their defaults.
Params
Every param has a kind, and may have a label (its name in words by default: endGap is End gap) and a hint, a line under the field in the dialog.
| Kind | The dialog shows | Your code gets | Options |
|---|---|---|---|
length | An expression with a length unit | ctx.value(name), in mm | default, check, optional |
angle | An expression with an angle unit | ctx.value(name), in radians | default, check, optional |
count | An expression of a whole number | ctx.value(name) | default, check, optional |
number | An expression of a plain number | ctx.value(name) | default, check, optional |
boolean | A check box | params[name], true or false | default |
choice | Buttons, or a list for over three | params[name], one of options | options, labels, default |
text | A text field | params[name], a string | default, maxLength |
regions | Closed areas of one sketch, picked | params[name]: { sketch, regions? }; no regions means all | optional |
curves | Lines, arcs and circles of a sketch | params[name]: { sketch, curves }, sketch entity ids | min, max, optional |
faces | Faces, picked | params[name]: [{ kind: 'face', name }], by topological name | min, max, optional |
edges | Edges, picked | params[name]: [{ kind: 'edge', name }], by topological name | min, max, optional |
bodies | Bodies, picked | params[name]: body ids | min, max, optional, modifies |
feature | A list of earlier features | params[name]: a feature id | types, optional |
newBody | Nothing | params[name]: the id of the body the feature makes |
- Number params are expressions, so people can type
width / 2or a parameter's name. Moket evaluates them before your code runs.checkrefuses values that are notpositive,nonzeroornonnegative; acountis never negative. defaultof a number is an expression too:"4 mm","30 deg","6".- A
newBodyparam is how a feature makes a body: Moket gives it an id, and your result must have a body under that id. A feature may make up to 8. bodieswithmodifies: trueare bodies the feature changes. Return them changed under their own ids.choiceoptions are names likeroundorchamfer;labelsgives each one words for the dialog, in the same order.- Picks are stored by name, so they keep pointing at the same faces and edges when the part changes. See Build a feature for reading them.
What Moket checks
When you install a plugin, Moket checks its manifest and lists what is wrong with it, for example:
- features.0.type: must start with com.example.rounded-box.
- params.radius.default: not one of the options
- workbench.tools: com.example.tools.slot is not a feature of the plugin
- sdk: the plugin needs SDK 2; this Moket runs SDK 1
When a part or an agent adds a feature, Moket checks its params against the manifest before your code runs: unknown params, wrong kinds and values outside check are refused with the field they are about.