Skip to content
BadBit Documentation
Sign in Download the beta

BadBit CAD operations

cad.annotate.table

Creates a table (TABLE, -TABLE).

  • Program: BadBit CAD
  • Type of action: Changes the drawing
  • Changes the drawing
  • Since version 2027.0.0-beta.8

Creates the TABLE table with the top left corner at position: with columns and data_rows (the data rows; the title and header come in addition, by the cell styles first_row and second_row), column_width and row_lines (the height in text lines); or with row_contents, the content row by row (like a table from CSV, the first row is the header). table_style picks the style (without it, the current one). Returns the identifier. In paper space (a layout on screen, outside the viewports), the coordinates and the measures are in mm; angles and scale factors do not change.

Parameters

NameTypeRequiredDescription
column_widthnumber | nullNoThe column width, in drawing units.
columnsinteger | nullNoNumber of columns.
data_rowsinteger | nullNoHow many data rows (the title and header come in addition).
first_rowRowKind | nullNoThe cell style of the first row: title, header or data.
positionarray<number>YesPosition [x, y] of a point or of a text (the insertion point).
row_contentsarray<array<string>> | nullNoThe table content, row by row [[text, …], …].
row_linesinteger | nullNoThe row height, in text lines.
second_rowRowKind | nullNoThe cell style of the second row: title, header or data.
table_stylestring | nullNoThe table style (it must exist).

Errors

CodeJSON-RPCMeaning
invalid_params-32602The parameters do not follow the schema or a rule of the operation.
not_found-32001The object, operation, file or name does not exist.
conflict-32004The current state does not allow this now.
failed-32005The operation failed.

Example

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

Commands that do the same

-TABLETABLE

Full schema

JSON Schema 2020-12.

Parameters (input)
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"
}
Result (output)
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"
}
Search the documentation