Pular para o conteúdo
BadBit Documentação
Entrar Baixar o beta

Operações da suíte

suite.batch.run

Roda uma lista de operações numa chamada, como uma transação e um desfazer só.

  • Programa: Todos os programas
  • Tipo de ação: Altera o desenho
  • Apaga
  • Desde a versão 2027.0.0-beta.6

O jeito de descrever um projeto inteiro de uma vez: cada passo tem operation, arguments e, opcionalmente, um id. Um passo usa o resultado de um anterior com o objeto ref: em qualquer lugar dos arguments, o objeto com a chave $ref e o valor "passo/caminho" vira o valor do resultado daquele passo no caminho (por exemplo "paredes/ids/0" é o primeiro objeto criado pelo passo paredes; o passo sem id é chamado pelo número, "0", "1"…). Tudo é um passo só do desfazer; se um passo falha, nada fica aplicado e o erro diz qual passo falhou e por quê. As operações que agem fora do desenho em segundo plano (exportar, imprimir, LandXML, eTransmit, o arquivo dos atributos, importar PDF, rodar código) não entram no lote. Até 20000 passos e 200000 objetos por operação; para mais, divida em vários lotes. Se falhar, as variáveis de sistema que o lote mudou (LTSCALE, OSMODE...) também voltam ao valor de antes. O lote não começa com um comando esperando resposta, e um passo que deixa um comando esperando (sem o Enter do fim) faz o lote falhar. Com a janela do BadBit aberta, o lote aparece na tela à medida que os passos se aplicam; prefira lotes de uma etapa (segundos), para a pessoa acompanhar e poder falar com você entre eles.

Ferramenta MCP
badbit_batch

Parâmetros

NomeTipoObrigatórioDescrição
stepsarray<BatchStep>SimNúmero de passos; no lote, os passos na ordem (cada um com operation, arguments e id opcional).

Erros

CódigoJSON-RPCO que significa
invalid_params-32602Os parâmetros não seguem o esquema ou uma regra da operação.
conflict-32004O estado atual não permite isso agora.
not_found-32001O objeto, a operação, o arquivo ou o nome não existe.
permission_denied-32002O pedido não é aceito (o detalhe diz por quê).
unsupported-32008Ainda não suportado.
failed-32005A operação falhou.

Exemplo

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, com as descrições em 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 (saída)
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 na documentação