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
| Name | Type | Required | Description |
|---|---|---|---|
ids | array<string> | null | No | Object identifiers (32 hexadecimal digits each). |
palette | string | Yes | The tool palette (by name). |
points | array<array<number>> | null | No | The points [[x, y], …], in order: the polyline vertices (at least 2), the fit or control points of the spline. |
position | array<number> | null | No | Position [x, y] of a point or of a text (the insertion point). |
tool | string | Yes | The palette tool (by name). |
Errors
| Code | JSON-RPC | Meaning |
|---|---|---|
invalid_params | -32602 | The parameters do not follow the schema or a rule of the operation. |
not_found | -32001 | The object, operation, file or name does not exist. |
permission_denied | -32002 | The request is not accepted (the detail says why). |
conflict | -32004 | The current state does not allow this now. |
busy | -32006 | BadBit is busy opening or saving a file; try again shortly. |
unsupported | -32008 | Not supported yet. |
failed | -32005 | The operation failed. |
Example
MCP
{
"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
import badbit
result = badbit.cad.toolpalette.use(palette="Arquitetura", position=[100, 50], tool="Porta")LISP
(badbit-call "cad.toolpalette.use" '(("palette" . "Arquitetura") ("position" . (100 50)) ("tool" . "Porta")))JSON-RPC
{
"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
Full schema
JSON Schema 2020-12.
Parameters (input)
{
"$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)
{
"$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"
}