BadBit CAD operations
cad.inquiry.area
Measures the area and perimeter of points or objects (AREA).
- Program: BadBit CAD
- Type of action: Reads the drawing
- Read only
- Since version 2027.0.0-beta.8
With points (at least three corners), the area and perimeter of the outline, like AREA by points. With ids, the area of each object (items) and the total, like AREA Object with Add; subtract_ids are subtracted from the total (Subtract). For an open object the area is that of the figure closed by the chord and the perimeter is the length, as in AutoCAD. Area in square drawing units (unit). Read only. On a layout's paper, in mm (unit "mm", the area in mm²): the points by the space on screen, the objects by their own space.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
ids | array<string> | null | No | Object identifiers (32 hexadecimal digits each). |
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. |
subtract_ids | array<string> | No | The regions that are taken away. |
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. |
failed | -32005 | The operation failed. |
Example
MCP
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"arguments": {
"points": [
[
0,
0
],
[
12,
0
],
[
12,
8
],
[
0,
8
]
]
},
"operation": "cad.inquiry.area"
},
"name": "badbit_call_operation"
}
}Python
import badbit
result = badbit.cad.inquiry.area(points=[[0, 0], [12, 0], [12, 8], [0, 8]])LISP
(badbit-call "cad.inquiry.area" '(("points" . ((0 0) (12 0) (12 8) (0 8)))))JSON-RPC
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"points": [
[
0,
0
],
[
12,
0
],
[
12,
8
],
[
0,
8
]
]
},
"operation": "cad.inquiry.area"
}
}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,
"minItems": 1,
"type": [
"array",
"null"
]
},
"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": 200000,
"minItems": 3,
"type": [
"array",
"null"
]
},
"subtract_ids": {
"default": [],
"description": "The regions that are taken away.",
"items": {
"type": "string"
},
"maxItems": 200000,
"type": "array"
}
},
"type": "object"
}Result (output)
{
"$defs": {
"AreaItem": {
"properties": {
"area": {
"description": "The area: in a measurement, the value (in square drawing units); in a capture, what becomes the image: view (what is on screen, the default), extents (everything drawn) or window.",
"format": "double",
"type": "number"
},
"closed": {
"description": "The polyline (or the spline) is closed (the last point connects to the first).",
"type": "boolean"
},
"id": {
"description": "Object identifier (32 hexadecimal digits), or command identifier in the command list.",
"type": "string"
},
"perimeter": {
"description": "The perimeter (for an open object, the length).",
"format": "double",
"type": "number"
},
"subtracted": {
"description": "Subtracted from the total.",
"type": "boolean"
}
},
"required": [
"id",
"area",
"perimeter",
"closed"
],
"type": "object"
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"area": {
"description": "The area: in a measurement, the value (in square drawing units); in a capture, what becomes the image: view (what is on screen, the default), extents (everything drawn) or window.",
"format": "double",
"type": "number"
},
"items": {
"description": "The items: the objects found, or the changes to make.",
"items": {
"$ref": "#/$defs/AreaItem"
},
"type": "array"
},
"perimeter": {
"description": "The perimeter (for an open object, the length).",
"format": "double",
"type": "number"
},
"unit": {
"description": "The unit of the numbers (the drawing unit symbol; area in square units, angles in degrees).",
"type": "string"
}
},
"required": [
"area",
"perimeter",
"unit"
],
"type": "object"
}