Operações do BadBit CAD
cad.inquiry.area
Mede a área e o perímetro de pontos ou de objetos (AREA).
- Programa: BadBit CAD
- Tipo de ação: Lê o desenho
- Só leitura
- Desde a versão 2027.0.0-beta.8
Com points (pelo menos três cantos), a área e o perímetro do contorno, como o AREA por pontos. Com ids, a área de cada objeto (items) e o total, como AREA Objeto com Somar; subtract_ids são subtraídos do total (Subtrair). Num objeto aberto a área é a da figura fechada pela corda e o perímetro é o comprimento, como no AutoCAD. Área em unidade² do desenho (unit). Só leitura. No papel de um layout, em mm (unit "mm", a área em mm²): os pontos pelo espaço à vista, os objetos pelo espaço deles.
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
ids | array<string> | null | Não | Identificadores de objetos (32 dígitos hexadecimais cada). |
points | array<array<number>> | null | Não | Os pontos [[x, y], …], na ordem: os vértices da polilinha (pelo menos 2), os pontos de ajuste ou de controle da spline. |
subtract_ids | array<string> | Não | As regiões que se tiram. |
Erros
| Código | JSON-RPC | O que significa |
|---|---|---|
invalid_params | -32602 | Os parâmetros não seguem o esquema ou uma regra da operação. |
not_found | -32001 | O objeto, a operação, o arquivo ou o nome não existe. |
failed | -32005 | A operação falhou. |
Exemplo
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"
}
}Comandos que fazem o mesmo
Esquema completo
JSON Schema 2020-12, com as descrições em inglês.
Parâmetros (entrada)
{
"$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 (saída)
{
"$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"
}