BadBit CAD operations
cad.draw.rectangle
Draws a rectangle (RECTANG) from two opposite corners.
- Program: BadBit CAD
- Type of action: Changes the drawing
- Changes the drawing
- Since version 2027.0.0-beta.8
Creates the closed polyline of the RECTANG command from corner1 to the opposite corner2, with the sides turned by rotation (degrees). Optional, as the command options: fillet (radius of rounded corners) or chamfer (the two distances), and polyline_width. On layer (it must exist) or on the current layer, with the current color and linetype. 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
| Name | Type | Required | Description |
|---|---|---|---|
chamfer | array<number> | null | No | The two chamfer distances of the corners [first, second]. |
corner1 | array<number> | Yes | One corner [x, y]. |
corner2 | array<number> | Yes | The opposite corner [x, y]. |
fillet | number | null | No | Radius of the rounded corners. |
layer | string | null | No | Layer name. |
polyline_width | number | null | No | Width of the polyline. |
rotation | number | null | No | Rotation in degrees, counterclockwise. |
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": {
"corner1": [
0,
0
],
"corner2": [
12,
8
]
},
"operation": "cad.draw.rectangle"
},
"name": "badbit_call_operation"
}
}Python
Python
import badbit
result = badbit.cad.draw.rectangle(corner1=[0, 0], corner2=[12, 8])LISP
LISP
(badbit-call "cad.draw.rectangle" '(("corner1" . (0 0)) ("corner2" . (12 8))))JSON-RPC
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"corner1": [
0,
0
],
"corner2": [
12,
8
]
},
"operation": "cad.draw.rectangle"
}
}Commands that do the same
Full schema
JSON Schema 2020-12.
Parameters (input)
JSON
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"chamfer": {
"default": null,
"description": "The two chamfer distances of the corners [first, second].",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": [
"array",
"null"
]
},
"corner1": {
"description": "One corner [x, y].",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"corner2": {
"description": "The opposite corner [x, y].",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"fillet": {
"default": null,
"description": "Radius of the rounded corners.",
"format": "double",
"type": [
"number",
"null"
]
},
"layer": {
"default": null,
"description": "Layer name.",
"type": [
"string",
"null"
]
},
"polyline_width": {
"default": null,
"description": "Width of the polyline.",
"format": "double",
"type": [
"number",
"null"
]
},
"rotation": {
"default": null,
"description": "Rotation in degrees, counterclockwise.",
"format": "double",
"type": [
"number",
"null"
]
}
},
"required": [
"corner1",
"corner2"
],
"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"
}