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

Operações do BadBit CAD

cad.annotate.table

Cria uma tabela (TABLE, -TABLE).

  • Programa: BadBit CAD
  • Tipo de ação: Altera o desenho
  • Altera o desenho
  • Desde a versão 2027.0.0-beta.8

Cria a tabela do TABLE com o canto de cima à esquerda em position: com columns e data_rows (as linhas de dados; o título e o cabeçalho vêm além delas, pelos estilos de célula first_row e second_row), column_width e row_lines (a altura em linhas de texto); ou com row_contents, o conteúdo linha a linha (como uma tabela vinda de CSV, a primeira linha é o cabeçalho). table_style escolhe o estilo (sem ele, o atual). Devolve o identificador. No papel (um layout à vista, fora das janelas de vista), as coordenadas e as medidas são em mm; os ângulos e os fatores de escala não mudam.

Parâmetros

NomeTipoObrigatórioDescrição
column_widthnumber | nullNãoA largura das colunas, em unidades do desenho.
columnsinteger | nullNãoNúmero de colunas.
data_rowsinteger | nullNãoQuantas linhas de dados (o título e o cabeçalho vêm além delas).
first_rowRowKind | nullNãoO estilo de célula da primeira linha: title, header ou data.
positionarray<number>SimPosição [x, y] de um ponto ou de um texto (o ponto de inserção).
row_contentsarray<array<string>> | nullNãoO conteúdo da tabela, linha a linha [[texto, …], …].
row_linesinteger | nullNãoA altura das linhas, em linhas de texto.
second_rowRowKind | nullNãoO estilo de célula da segunda linha: title, header ou data.
table_stylestring | nullNãoO estilo de tabela (tem de existir).

Erros

CódigoJSON-RPCO que significa
invalid_params-32602Os parâmetros não seguem o esquema ou uma regra da operação.
not_found-32001O objeto, a operação, o arquivo ou o nome não existe.
conflict-32004O estado atual não permite isso agora.
failed-32005A operação falhou.

Exemplo

MCP

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "arguments": {
        "columns": 3,
        "data_rows": 2,
        "position": [
          0,
          0
        ]
      },
      "operation": "cad.annotate.table"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.annotate.table(columns=3, data_rows=2, position=[0, 0])

LISP

LISP
(badbit-call "cad.annotate.table" '(("columns" . 3) ("data_rows" . 2) ("position" . (0 0))))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "columns": 3,
      "data_rows": 2,
      "position": [
        0,
        0
      ]
    },
    "operation": "cad.annotate.table"
  }
}

Comandos que fazem o mesmo

-TABLETABLE

Esquema completo

JSON Schema 2020-12, com as descrições em inglês.

Parâmetros (entrada)
JSON
{
  "$defs": {
    "RowKind": {
      "oneOf": [
        {
          "const": "title",
          "type": "string"
        },
        {
          "const": "header",
          "type": "string"
        },
        {
          "const": "data",
          "type": "string"
        }
      ]
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "column_width": {
      "default": null,
      "description": "The column width, in drawing units.",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "columns": {
      "default": null,
      "description": "Number of columns.",
      "format": "uint",
      "maximum": 1000,
      "minimum": 1,
      "type": [
        "integer",
        "null"
      ]
    },
    "data_rows": {
      "default": null,
      "description": "How many data rows (the title and header come in addition).",
      "format": "uint",
      "maximum": 10000,
      "minimum": 1,
      "type": [
        "integer",
        "null"
      ]
    },
    "first_row": {
      "anyOf": [
        {
          "$ref": "#/$defs/RowKind"
        },
        {
          "type": "null"
        }
      ],
      "description": "The cell style of the first row: title, header or data."
    },
    "position": {
      "description": "Position [x, y] of a point or of a text (the insertion point).",
      "items": {
        "format": "double",
        "type": "number"
      },
      "maxItems": 2,
      "minItems": 2,
      "type": "array"
    },
    "row_contents": {
      "default": null,
      "description": "The table content, row by row [[text, …], …].",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "maxItems": 10000,
      "minItems": 1,
      "type": [
        "array",
        "null"
      ]
    },
    "row_lines": {
      "default": null,
      "description": "The row height, in text lines.",
      "format": "uint",
      "maximum": 100,
      "minimum": 1,
      "type": [
        "integer",
        "null"
      ]
    },
    "second_row": {
      "anyOf": [
        {
          "$ref": "#/$defs/RowKind"
        },
        {
          "type": "null"
        }
      ],
      "description": "The cell style of the second row: title, header or data."
    },
    "table_style": {
      "default": null,
      "description": "The table style (it must exist).",
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "position"
  ],
  "type": "object"
}
Resultado (saída)
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "ids": {
      "description": "Object identifiers (32 hexadecimal digits each).",
      "items": {
        "type": "string"
      },
      "type": "array"
    }
  },
  "required": [
    "ids"
  ],
  "type": "object"
}
Buscar na documentação