Saltar al contenido
BadBit Documentación
Iniciar sesión Descargar la beta

Operaciones de BadBit CAD

cad.inquiry.area

Mide el área y el perímetro de puntos u objetos (AREA).

  • Programa: BadBit CAD
  • Tipo de acción: Lee el dibujo
  • Solo lectura
  • Desde la versión 2027.0.0-beta.8

Con points (al menos tres esquinas), el área y el perímetro del contorno, como AREA por puntos. Con ids, el área de cada objeto (items) y el total, como AREA Objeto con Añadir; subtract_ids se restan del total (Sustraer). En un objeto abierto el área es la de la figura cerrada por la cuerda y el perímetro es la longitud, como en AutoCAD. Área en unidades² del dibujo (unit). Solo lectura. En el papel de una presentación, en mm (unit "mm", el área en mm²): los puntos por el espacio a la vista, los objetos por su propio espacio.

Parámetros

NombreTipoObligatorioDescripción
idsarray<string> | nullNoIdentificadores de objetos (32 dígitos hexadecimales cada uno).
pointsarray<array<number>> | nullNoLos puntos [[x, y], …], en orden: los vértices de la polilínea (al menos 2), los puntos de ajuste o de control de la spline.
subtract_idsarray<string>NoLas regiones que se quitan.

Errores

CódigoJSON-RPCQué significa
invalid_params-32602Los parámetros no siguen el esquema o una regla de la operación.
not_found-32001El objeto, la operación, el archivo o el nombre no existe.
failed-32005La operación falló.

Ejemplo

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"
  }
}

Comandos que hacen lo mismo

AREA

Esquema completo

JSON Schema 2020-12, con las descripciones en inglés.

Parámetros (entrada)
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"
}
Resultado (salida)
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"
}
Buscar en la documentación