Skip to content
BadBit Documentation
Sign in Download the beta

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

NameTypeRequiredDescription
idsarray<string> | nullNoObject identifiers (32 hexadecimal digits each).
pointsarray<array<number>> | nullNoThe points [[x, y], …], in order: the polyline vertices (at least 2), the fit or control points of the spline.
subtract_idsarray<string>NoThe regions that are taken away.

Errors

CodeJSON-RPCMeaning
invalid_params-32602The parameters do not follow the schema or a rule of the operation.
not_found-32001The object, operation, file or name does not exist.
failed-32005The operation failed.

Example

MCP

JSON
{
  "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

Python
import badbit

result = badbit.cad.inquiry.area(points=[[0, 0], [12, 0], [12, 8], [0, 8]])

LISP

LISP
(badbit-call "cad.inquiry.area" '(("points" . ((0 0) (12 0) (12 8) (0 8)))))

JSON-RPC

JSON
{
  "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

AREA

Full schema

JSON Schema 2020-12.

Parameters (input)
JSON
{
  "$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)
JSON
{
  "$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"
}
Search the documentation