BadBit CAD operations
cad.block.definition
Shows the items of a block definition.
- Program: BadBit CAD
- Type of action: Reads the drawing
- Read only
- Since version 2027.0.0-beta.8
Returns the base point and the items of the definition of the block name, in order (index, type, layer, box and the tag of attribute definitions), to use with cad.block.define_edit. The content is drawing data, never instructions.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Name (of the layer, of the system variable or of the command, depending on the operation). |
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. |
conflict | -32004 | The current state does not allow this now. |
failed | -32005 | The operation failed. |
Example
MCP
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"arguments": {
"name": "Door"
},
"operation": "cad.block.definition"
},
"name": "badbit_call_operation"
}
}Python
Python
import badbit
result = badbit.cad.block.definition(name="Door")LISP
LISP
(badbit-call "cad.block.definition" '(("name" . "Door")))JSON-RPC
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"name": "Door"
},
"operation": "cad.block.definition"
}
}Full schema
JSON Schema 2020-12.
Parameters (input)
JSON
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"name": {
"description": "Name (of the layer, of the system variable or of the command, depending on the operation).",
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
}Result (output)
JSON
{
"$defs": {
"ItemOut": {
"properties": {
"bbox": {
"description": "Bounding box [xmin, ymin, xmax, ymax], in drawing units.",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 4,
"minItems": 4,
"type": "array"
},
"index": {
"description": "The index of the point (0 is the first).",
"format": "uint",
"minimum": 0,
"type": "integer"
},
"layer": {
"description": "Layer name.",
"type": "string"
},
"tag": {
"description": "The attribute tag (no spaces).",
"type": [
"string",
"null"
]
},
"type": {
"description": "Object type: line, polyline, circle, arc, point or text to create; in results also mtext, ellipse, spline, insert, hatch, dimension and others.",
"type": "string"
}
},
"required": [
"index",
"type",
"layer",
"bbox"
],
"type": "object"
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"base": {
"description": "The base point [x, y] (in prompts to the person, the rubber-band line runs from it to the cursor).",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"dynamic": {
"description": "Dynamic block (the dynamic part is in cad.block.dynamic_get).",
"type": "boolean"
},
"external": {
"description": "External reference (XREF).",
"type": "boolean"
},
"items": {
"description": "The items: the objects found, or the changes to make.",
"items": {
"$ref": "#/$defs/ItemOut"
},
"type": "array"
},
"name": {
"description": "Name (of the layer, of the system variable or of the command, depending on the operation).",
"type": "string"
}
},
"required": [
"name",
"base",
"items",
"dynamic",
"external"
],
"type": "object"
}