Saltar al contenido
BadBit Documentación
Iniciar sesión Descargar la beta

Operaciones de la suite

suite.batch.run

Ejecuta una lista de operaciones en una llamada, como una transacción y un único paso de deshacer.

  • Programa: Todos los programas
  • Tipo de acción: Cambia el dibujo
  • Borra
  • Desde la versión 2027.0.0-beta.6

La forma de describir un proyecto entero de una vez: cada paso tiene operation, arguments y, opcionalmente, un id. Un paso usa el resultado de uno anterior con el objeto ref: en cualquier lugar de los arguments, el objeto con la clave $ref y el valor "paso/ruta" se convierte en el valor del resultado de ese paso en esa ruta (por ejemplo "paredes/ids/0" es el primer objeto creado por el paso paredes; el paso sin id se nombra por su número, "0", "1"…). Todo es un paso de deshacer; si un paso falla, no se aplica nada y el error dice qué paso falló y por qué. Las operaciones que actúan fuera del dibujo en segundo plano (exportar, imprimir, LandXML, eTransmit, el archivo de los atributos, importar PDF, ejecutar código) no entran en un lote. Hasta 20000 pasos y 200000 objetos por operación; para más, divídalo en varios lotes. Si falla, las variables de sistema que el lote cambió (LTSCALE, OSMODE...) también vuelven a su valor anterior. El lote no empieza con un comando esperando respuesta, y un paso que deja un comando esperando (sin el Intro del final) hace fallar el lote. Con la ventana de BadBit abierta, el lote aparece en la pantalla a medida que se aplican los pasos; prefiera lotes de una etapa (segundos), para que la persona acompañe y pueda hablar con usted entre ellos.

Herramienta MCP
badbit_batch

Parámetros

NombreTipoObligatorioDescripción
stepsarray<BatchStep>SíNúmero de pasos; en un lote, los pasos en orden (cada uno con operation, arguments e id opcional).

Errores

CódigoJSON-RPCQué significa
invalid_params-32602Los parámetros no siguen el esquema o una regla de la operación.
conflict-32004El estado actual no lo permite ahora.
not_found-32001El objeto, la operación, el archivo o el nombre no existe.
permission_denied-32002La petición no se acepta (el detalle dice por qué).
unsupported-32008Todavía no soportado.
failed-32005La operación falló.

Ejemplo

MCP

JSON
{
  "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

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

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

JSON
{
  "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"
  }
}

Esquema completo

JSON Schema 2020-12, con las descripciones en inglés.

Parámetros (entrada)
JSON
{
  "$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"
}
Resultado (salida)
JSON
{
  "$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"
}
Buscar en la documentación