Skip to content

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"]
    }
  ]
}
FieldWhat it is
idA reverse domain of your own, such as com.yourname.tools. Ids that start with io.moket. are Moket's
nameThe plugin's name in Settings, the workbench picker and the banner of parts that use it
version1.0.0 style. Raise it when you change the plugin
sdkThe SDK it is written for: 1
authorOptional, shown when someone installs the plugin
descriptionOptional, shown when someone installs the plugin
homepageOptional, an https address
mainThe module next to the manifest, plugin.js by default
featuresUp to 100 features
workbenchOptional: its label in the workbench picker and its tools, feature types of this plugin in toolbar order
exportsOptional: up to 20 exports, each an id, a label for its button and the formats it offers. See Export from a plugin

Features ​

FieldWhat it is
typeThe plugin's id, a dot and a name: com.example.rounded-box.box. Parts store features by type
versionThe version of its params, from 1. Raise it when you rename or remove a param
labelIts name on the toolbar and in the history; new features are named after it (Rounded box1)
descriptionOptional, one sentence. Agents read it to choose the feature
iconOptional, SVG path data on a 24 x 24 grid, drawn as a line
paramsUp 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.

KindThe dialog showsYour code getsOptions
lengthAn expression with a length unitctx.value(name), in mmdefault, check, optional
angleAn expression with an angle unitctx.value(name), in radiansdefault, check, optional
countAn expression of a whole numberctx.value(name)default, check, optional
numberAn expression of a plain numberctx.value(name)default, check, optional
booleanA check boxparams[name], true or falsedefault
choiceButtons, or a list for over threeparams[name], one of optionsoptions, labels, default
textA text fieldparams[name], a stringdefault, maxLength
regionsClosed areas of one sketch, pickedparams[name]: { sketch, regions? }; no regions means alloptional
curvesLines, arcs and circles of a sketchparams[name]: { sketch, curves }, sketch entity idsmin, max, optional
facesFaces, pickedparams[name]: [{ kind: 'face', name }], by topological namemin, max, optional
edgesEdges, pickedparams[name]: [{ kind: 'edge', name }], by topological namemin, max, optional
bodiesBodies, pickedparams[name]: body idsmin, max, optional, modifies
featureA list of earlier featuresparams[name]: a feature idtypes, optional
newBodyNothingparams[name]: the id of the body the feature makes
  • Number params are expressions, so people can type width / 2 or a parameter's name. Moket evaluates them before your code runs. check refuses values that are not positive, nonzero or nonnegative; a count is never negative.
  • default of a number is an expression too: "4 mm", "30 deg", "6".
  • A newBody param 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.
  • bodies with modifies: true are bodies the feature changes. Return them changed under their own ids.
  • choice options are names like round or chamfer; labels gives 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.

Moket Help