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

Operaciones de BadBit CAD

cad.annotate.table

Crea una tabla (TABLE, -TABLE).

  • Programa: BadBit CAD
  • Tipo de acción: Cambia el dibujo
  • Modifica el dibujo
  • Desde la versión 2027.0.0-beta.8

Crea la tabla de TABLE con la esquina superior izquierda en position: con columns y data_rows (las filas de datos; el título y el encabezado van además, por los estilos de celda first_row y second_row), column_width y row_lines (la altura en líneas de texto); o con row_contents, el contenido fila a fila (como una tabla de CSV, la primera fila es el encabezado). table_style elige el estilo (sin él, el actual). Devuelve el identificador. En el papel (una presentación a la vista, fuera de las ventanas gráficas), las coordenadas y las medidas son en mm; los ángulos y los factores de escala no cambian.

Parámetros

NombreTipoObligatorioDescripción
column_widthnumber | nullNoLa anchura de las columnas, en unidades del dibujo.
columnsinteger | nullNoNúmero de columnas.
data_rowsinteger | nullNoCuántas filas de datos (el título y el encabezado van además).
first_rowRowKind | nullNoEl estilo de celda de la primera fila: title, header o data.
positionarray<number>SíPosición [x, y] de un punto o de un texto (el punto de inserción).
row_contentsarray<array<string>> | nullNoEl contenido de la tabla, fila a fila [[texto, …], …].
row_linesinteger | nullNoLa altura de las filas, en líneas de texto.
second_rowRowKind | nullNoEl estilo de celda de la segunda fila: title, header o data.
table_stylestring | nullNoEl estilo de tabla (tiene que existir).

Errores

CódigoJSON-RPCQué significa
invalid_params-32602Los parámetros no siguen el esquema o una regla de la operación.
not_found-32001El objeto, la operación, el archivo o el nombre no existe.
conflict-32004El estado actual no lo permite ahora.
failed-32005La operación falló.

Ejemplo

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 hacen lo mismo

-TABLETABLE

Esquema completo

JSON Schema 2020-12, con las descripciones en 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 (salida)
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 en la documentación