Skip to content
BadBit Documentation
Sign in Download the beta

BadBit CAD operations

cad.toolpalette.use

Uses a palette tool in the drawing (TOOLPALETTES).

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

Uses the tool tool of the palette palette like clicking it: a block tool inserts the block (brought from the library, the current drawing or the file) at position with its scale and rotation; a hatch or gradient tool fills the area around points or the boundary ids; the tool's layer, color and linetype go to what it created. A command tool does not run through automation: its text is in cad.toolpalette.list, to send with suite.command.run. One undo step. Returns what changed. 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
idsarray<string> | nullNoObject identifiers (32 hexadecimal digits each).
palettestringYesThe tool palette (by name).
pointsarray<array<number>> | nullNoThe points [[x, y], …], in order: the polyline vertices (at least 2), the fit or control points of the spline.
positionarray<number> | nullNoPosition [x, y] of a point or of a text (the insertion point).
toolstringYesThe palette tool (by name).

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.
permission_denied-32002The request is not accepted (the detail says why).
conflict-32004The current state does not allow this now.
busy-32006BadBit is busy opening or saving a file; try again shortly.
unsupported-32008Not supported yet.
failed-32005The operation failed.

Example

MCP

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "arguments": {
        "palette": "Arquitetura",
        "position": [
          100,
          50
        ],
        "tool": "Porta"
      },
      "operation": "cad.toolpalette.use"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.toolpalette.use(palette="Arquitetura", position=[100, 50], tool="Porta")

LISP

LISP
(badbit-call "cad.toolpalette.use" '(("palette" . "Arquitetura") ("position" . (100 50)) ("tool" . "Porta")))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "palette": "Arquitetura",
      "position": [
        100,
        50
      ],
      "tool": "Porta"
    },
    "operation": "cad.toolpalette.use"
  }
}

Commands that do the same

TOOLPALETTES

Full schema

JSON Schema 2020-12.

Parameters (input)
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "ids": {
      "default": null,
      "description": "Object identifiers (32 hexadecimal digits each).",
      "items": {
        "type": "string"
      },
      "maxItems": 200000,
      "type": [
        "array",
        "null"
      ]
    },
    "palette": {
      "description": "The tool palette (by name).",
      "maxLength": 255,
      "minLength": 1,
      "type": "string"
    },
    "points": {
      "default": null,
      "description": "The points [[x, y], …], in order: the polyline vertices (at least 2), the fit or control points of the spline.",
      "items": {
        "items": {
          "format": "double",
          "type": "number"
        },
        "maxItems": 2,
        "minItems": 2,
        "type": "array"
      },
      "maxItems": 1000,
      "type": [
        "array",
        "null"
      ]
    },
    "position": {
      "default": null,
      "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",
        "null"
      ]
    },
    "tool": {
      "description": "The palette tool (by name).",
      "maxLength": 255,
      "minLength": 1,
      "type": "string"
    }
  },
  "required": [
    "palette",
    "tool"
  ],
  "type": "object"
}
Result (output)
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "created": {
      "description": "Identifiers of the objects created.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "deleted": {
      "description": "The identifiers of what was deleted.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "document_changed": {
      "description": "The drawing on screen is another one (opened, closed or changed tab): the lists of changes do not apply.",
      "type": "boolean"
    },
    "modified": {
      "description": "Whether there are unsaved changes; in results of changes, the identifiers of the objects changed.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "truncated": {
      "description": "The lists were cut at the limit.",
      "type": "boolean"
    }
  },
  "required": [
    "created",
    "modified",
    "deleted",
    "document_changed",
    "truncated"
  ],
  "type": "object"
}
Search the documentation