Suite operations
suite.batch.run
Runs a list of operations in one call, as a single transaction and a single undo step.
- Program: All programs
- Type of action: Changes the drawing
- Deletes
- Since version 2027.0.0-beta.6
The way to describe a whole project at once: each step has operation, arguments and, optionally, an id. A step uses the result of an earlier one with a ref object: anywhere in the arguments, the object with the key $ref and the value "step/path" becomes the value of that step's result at that path (for example "walls/ids/0" is the first object created by the step walls; a step without id is named by its number, "0", "1"…). Everything is one undo step; if a step fails, nothing is applied and the error says which step failed and why. Operations that act outside the drawing in the background (export, print, LandXML, eTransmit, the attributes file, PDF import, running code) do not go in a batch. Up to 20000 steps and 200000 objects per operation; for more, split into several batches. If it fails, the system variables the batch changed (LTSCALE, OSMODE...) also go back to their previous value. A batch does not start while a command is waiting for an answer, and a step that leaves a command waiting (without the final Enter) makes the batch fail. With the BadBit window open, the batch shows up on screen as its steps are applied; prefer one-stage batches (seconds), so the person can follow along and talk to you between them.
- MCP tool
badbit_batch
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
steps | array<BatchStep> | Yes | Number of steps; in a batch, the steps in order (each with operation, arguments and an optional id). |
Errors
| Code | JSON-RPC | Meaning |
|---|---|---|
invalid_params | -32602 | The parameters do not follow the schema or a rule of the operation. |
conflict | -32004 | The current state does not allow this now. |
not_found | -32001 | The object, operation, file or name does not exist. |
permission_denied | -32002 | The request is not accepted (the detail says why). |
unsupported | -32008 | Not supported yet. |
failed | -32005 | The operation failed. |
Example
MCP
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"steps": [
{
"arguments": {
"color": 1,
"name": "Walls"
},
"id": "walls",
"operation": "cad.layer.create"
},
{
"arguments": {
"entities": [
{
"closed": true,
"layer": "Walls",
"points": [
[
0,
0
],
[
500,
0
],
[
500,
400
],
[
0,
400
]
],
"type": "polyline"
},
{
"content": "Living room",
"height": 20,
"position": [
200,
200
],
"type": "text"
}
]
},
"id": "room",
"operation": "cad.entity.create"
},
{
"arguments": {
"items": [
{
"id": {
"$ref": "room/ids/1"
},
"set": {
"color": "blue"
}
}
]
},
"operation": "cad.entity.modify"
}
]
},
"name": "badbit_batch"
}
}Python
import badbit
result = badbit.suite.batch.run(steps=[{"arguments": {"color": 1, "name": "Walls"}, "id": "walls", "operation": "cad.layer.create"}, {"arguments": {"entities": [{"closed": True, "layer": "Walls", "points": [[0, 0], [500, 0], [500, 400], [0, 400]], "type": "polyline"}, {"content": "Living room", "height": 20, "position": [200, 200], "type": "text"}]}, "id": "room", "operation": "cad.entity.create"}, {"arguments": {"items": [{"id": {"$ref": "room/ids/1"}, "set": {"color": "blue"}}]}, "operation": "cad.entity.modify"}])LISP
(badbit-call "suite.batch.run" '(("steps" . ((("arguments" . (("color" . 1) ("name" . "Walls"))) ("id" . "walls") ("operation" . "cad.layer.create")) (("arguments" . (("entities" . ((("closed" . T) ("layer" . "Walls") ("points" . ((0 0) (500 0) (500 400) (0 400))) ("type" . "polyline")) (("content" . "Living room") ("height" . 20) ("position" . (200 200)) ("type" . "text")))))) ("id" . "room") ("operation" . "cad.entity.create")) (("arguments" . (("items" . ((("id" . (("$ref" . "room/ids/1"))) ("set" . (("color" . "blue")))))))) ("operation" . "cad.entity.modify"))))))JSON-RPC
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"steps": [
{
"arguments": {
"color": 1,
"name": "Walls"
},
"id": "walls",
"operation": "cad.layer.create"
},
{
"arguments": {
"entities": [
{
"closed": true,
"layer": "Walls",
"points": [
[
0,
0
],
[
500,
0
],
[
500,
400
],
[
0,
400
]
],
"type": "polyline"
},
{
"content": "Living room",
"height": 20,
"position": [
200,
200
],
"type": "text"
}
]
},
"id": "room",
"operation": "cad.entity.create"
},
{
"arguments": {
"items": [
{
"id": {
"$ref": "room/ids/1"
},
"set": {
"color": "blue"
}
}
]
},
"operation": "cad.entity.modify"
}
]
},
"operation": "suite.batch.run"
}
}Full schema
JSON Schema 2020-12.
Parameters (input)
{
"$defs": {
"BatchStep": {
"additionalProperties": false,
"properties": {
"arguments": {
"default": null,
"description": "The parameters of the operation, with $ref references to earlier steps."
},
"id": {
"default": null,
"description": "Object identifier (32 hexadecimal digits), or command identifier in the command list.",
"maxLength": 64,
"minLength": 1,
"type": [
"string",
"null"
]
},
"operation": {
"description": "The typed operation that does the same.",
"maxLength": 96,
"minLength": 3,
"type": "string"
}
},
"required": [
"operation"
],
"type": "object"
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"steps": {
"description": "Number of steps; in a batch, the steps in order (each with operation, arguments and an optional id).",
"items": {
"$ref": "#/$defs/BatchStep"
},
"maxItems": 20000,
"minItems": 1,
"type": "array"
}
},
"required": [
"steps"
],
"type": "object"
}Result (output)
{
"$defs": {
"BatchResult": {
"properties": {
"id": {
"description": "Object identifier (32 hexadecimal digits), or command identifier in the command list.",
"type": "string"
},
"operation": {
"description": "The typed operation that does the same.",
"type": "string"
},
"result": {
"description": "The result of the step's operation."
}
},
"required": [
"id",
"operation",
"result"
],
"type": "object"
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"results": {
"description": "The results, one per step, in order.",
"items": {
"$ref": "#/$defs/BatchResult"
},
"type": "array"
}
},
"required": [
"results"
],
"type": "object"
}