Pular para o conteúdo
BadBit Documentação
Entrar Baixar o beta

Operações do BadBit CAD

cad.parametric.dimensional

Aplica uma restrição dimensional (DIMCONSTRAINT, DCLINEAR, DCALIGNED, DCRADIUS...).

  • Programa: BadBit CAD
  • Tipo de ação: Altera o desenho
  • Altera o desenho
  • Desde a versão 2027.0.0-beta.8

Cria a restrição dimensional constraint (linear, horizontal, vertical, aligned, angular, radius, diameter) nas partes parts (dois pontos, uma linha, duas linhas ou um arco), com a linha de cota em dim_line_point. expression dá o valor (um número ou uma expressão com outros parâmetros; nos ângulos, graus; sem ela, a medida atual) e o solver ajusta a geometria; param_name dá o nome (sem ele, d1, ang1, rad1, dia1). Com as_reference, vira cota de referência (só mede). Devolve o identificador e o que mudou.

Parâmetros

NomeTipoObrigatórioDescrição
as_referencebooleanNãoCria como cota de referência (mede, não dirige a geometria).
constraintDimSpecSimA restrição.
dim_line_pointarray<number>SimUm ponto [x, y] por onde passa a linha (ou o arco) de cota; nas de raio e na ordenada, onde fica o texto.
expressionstring | nullNãoO valor: um número ou uma expressão com outros parâmetros (nos ângulos, graus); no CAL, a expressão a calcular.
param_namestring | nullNãoO nome do parâmetro (dado do desenho, nos resultados).
partsarray<Part>SimAs partes, cada uma com id e part (whole, start, end, mid, center, {"vertex_index": n}, {"segment": n}, {"segment_mid": n}, major_axis, minor_axis).

Erros

CódigoJSON-RPCO que significa
invalid_params-32602Os parâmetros não seguem o esquema ou uma regra da operação.
not_found-32001O objeto, a operação, o arquivo ou o nome não existe.
conflict-32004O estado atual não permite isso agora.
failed-32005A operação falhou.

Exemplo

MCP

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "arguments": {
        "constraint": "aligned",
        "dim_line_point": [
          5,
          2
        ],
        "expression": "5",
        "parts": [
          {
            "id": "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"
          }
        ]
      },
      "operation": "cad.parametric.dimensional"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.parametric.dimensional(constraint="aligned", dim_line_point=[5, 2], expression="5", parts=[{"id": "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"}])

LISP

LISP
(badbit-call "cad.parametric.dimensional" '(("constraint" . "aligned") ("dim_line_point" . (5 2)) ("expression" . "5") ("parts" . ((("id" . "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"))))))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "constraint": "aligned",
      "dim_line_point": [
        5,
        2
      ],
      "expression": "5",
      "parts": [
        {
          "id": "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"
        }
      ]
    },
    "operation": "cad.parametric.dimensional"
  }
}

Comandos que fazem o mesmo

DCALIGNEDDCANGULARDCDIAMETERDCHORIZONTALDCLINEARDCRADIUSDCVERTICALDIMCONSTRAINT

Esquema completo

JSON Schema 2020-12, com as descrições em inglês.

Parâmetros (entrada)
JSON
{
  "$defs": {
    "DimSpec": {
      "oneOf": [
        {
          "const": "linear",
          "type": "string"
        },
        {
          "const": "horizontal",
          "type": "string"
        },
        {
          "const": "vertical",
          "type": "string"
        },
        {
          "const": "aligned",
          "type": "string"
        },
        {
          "const": "angular",
          "type": "string"
        },
        {
          "const": "radius",
          "type": "string"
        },
        {
          "const": "diameter",
          "type": "string"
        }
      ]
    },
    "Part": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "Object identifier (32 hexadecimal digits), or command identifier in the command list.",
          "type": "string"
        },
        "part": {
          "$ref": "#/$defs/PartSpec",
          "description": "The part of the object (default: whole)."
        }
      },
      "required": [
        "id"
      ],
      "type": "object"
    },
    "PartSpec": {
      "oneOf": [
        {
          "const": "whole",
          "type": "string"
        },
        {
          "const": "start",
          "type": "string"
        },
        {
          "const": "end",
          "type": "string"
        },
        {
          "const": "mid",
          "type": "string"
        },
        {
          "const": "center",
          "type": "string"
        },
        {
          "additionalProperties": false,
          "properties": {
            "vertex_index": {
              "description": "The number of the polyline vertex (from 0).",
              "format": "uint32",
              "minimum": 0,
              "type": "integer"
            }
          },
          "required": [
            "vertex_index"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "segment": {
              "description": "The number of the polyline segment (from 0).",
              "format": "uint32",
              "minimum": 0,
              "type": "integer"
            }
          },
          "required": [
            "segment"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "segment_mid": {
              "description": "The number of the polyline segment whose midpoint the constraint holds (from 0).",
              "format": "uint32",
              "minimum": 0,
              "type": "integer"
            }
          },
          "required": [
            "segment_mid"
          ],
          "type": "object"
        },
        {
          "const": "major_axis",
          "type": "string"
        },
        {
          "const": "minor_axis",
          "type": "string"
        }
      ]
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "as_reference": {
      "default": false,
      "description": "Creates it as a reference dimension (it measures, it does not drive the geometry).",
      "type": "boolean"
    },
    "constraint": {
      "$ref": "#/$defs/DimSpec",
      "description": "The constraint."
    },
    "dim_line_point": {
      "description": "A point [x, y] the dimension line (or arc) passes through; in radial and ordinate dimensions, where the text goes.",
      "items": {
        "format": "double",
        "type": "number"
      },
      "maxItems": 2,
      "minItems": 2,
      "type": "array"
    },
    "expression": {
      "default": null,
      "description": "The value: a number or an expression with other parameters (for angles, degrees); in CAL, the expression to calculate.",
      "maxLength": 10000,
      "minLength": 1,
      "type": [
        "string",
        "null"
      ]
    },
    "param_name": {
      "default": null,
      "description": "The parameter name (data from the drawing, in results).",
      "maxLength": 255,
      "minLength": 1,
      "type": [
        "string",
        "null"
      ]
    },
    "parts": {
      "description": "The parts, each with id and part (whole, start, end, mid, center, {\"vertex_index\": n}, {\"segment\": n}, {\"segment_mid\": n}, major_axis, minor_axis).",
      "items": {
        "$ref": "#/$defs/Part"
      },
      "maxItems": 3,
      "minItems": 1,
      "type": "array"
    }
  },
  "required": [
    "constraint",
    "parts",
    "dim_line_point"
  ],
  "type": "object"
}
Resultado (saída)
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "constraint_id": {
      "description": "The constraint identifier.",
      "type": "string"
    },
    "created": {
      "description": "Identifiers of the objects created.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "deleted": {
      "description": "The identifiers of what was deleted.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "document_changed": {
      "description": "The drawing on screen is another one (opened, closed or changed tab): the lists of changes do not apply.",
      "type": "boolean"
    },
    "modified": {
      "description": "Whether there are unsaved changes; in results of changes, the identifiers of the objects changed.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "skipped_locked": {
      "description": "Objects left as they were because they are on locked layers.",
      "format": "uint",
      "minimum": 0,
      "type": "integer"
    },
    "truncated": {
      "description": "The lists were cut at the limit.",
      "type": "boolean"
    }
  },
  "required": [
    "constraint_id",
    "created",
    "modified",
    "deleted",
    "document_changed",
    "truncated"
  ],
  "type": "object"
}
Buscar na documentação