BadBit CAD operations
cad.draw.polygon
Draws a regular polygon (POLYGON) by center and radius or by one edge.
- 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 POLYGON command with sides sides (3 to 1024): with center and radius, inscribed in the circle (the default) or circumscribed about it, the first vertex (or the middle of the first side) toward rotation degrees; or with edge, the two ends of the first side, the others counterclockwise. 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 |
|---|---|---|---|
center | array<number> | null | No | Center point [x, y]. |
edge | array<array<number>> | null | No | The two ends of the first side [[x, y], [x, y]]. |
inscribed | boolean | null | No | Inscribed in the circle (true, the default) or circumscribed about it (false). |
layer | string | null | No | Layer name. |
radius | number | null | No | Radius, in drawing units. |
rotation | number | null | No | Rotation in degrees, counterclockwise. |
sides | integer | Yes | Number of sides (3 to 1024). |
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": {
"center": [
0,
0
],
"radius": 10,
"sides": 6
},
"operation": "cad.draw.polygon"
},
"name": "badbit_call_operation"
}
}Python
Python
import badbit
result = badbit.cad.draw.polygon(center=[0, 0], radius=10, sides=6)LISP
LISP
(badbit-call "cad.draw.polygon" '(("center" . (0 0)) ("radius" . 10) ("sides" . 6)))JSON-RPC
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"center": [
0,
0
],
"radius": 10,
"sides": 6
},
"operation": "cad.draw.polygon"
}
}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": {
"center": {
"default": null,
"description": "Center point [x, y].",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": [
"array",
"null"
]
},
"edge": {
"default": null,
"description": "The two ends of the first side [[x, y], [x, y]].",
"items": {
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"maxItems": 2,
"minItems": 2,
"type": [
"array",
"null"
]
},
"inscribed": {
"default": null,
"description": "Inscribed in the circle (true, the default) or circumscribed about it (false).",
"type": [
"boolean",
"null"
]
},
"layer": {
"default": null,
"description": "Layer name.",
"type": [
"string",
"null"
]
},
"radius": {
"default": null,
"description": "Radius, in drawing units.",
"format": "double",
"type": [
"number",
"null"
]
},
"rotation": {
"default": null,
"description": "Rotation in degrees, counterclockwise.",
"format": "double",
"type": [
"number",
"null"
]
},
"sides": {
"description": "Number of sides (3 to 1024).",
"format": "uint32",
"maximum": 1024,
"minimum": 3,
"type": "integer"
}
},
"required": [
"sides"
],
"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"
}