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

Operações do BadBit CAD

cad.parametric.geometric

Aplica uma restrição geométrica (GEOMCONSTRAINT, GCHORIZONTAL, GCPARALLEL...).

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

Aplica a restrição constraint (coincident, collinear, concentric, fix, parallel, perpendicular, horizontal, vertical, tangent, smooth, symmetric, equal) às partes parts (cada uma com id e part: whole, start, end, mid, center, {"vertex_index": n}...), na ordem das perguntas do comando: a primeira fica, a segunda se ajusta. O solver move a geometria no mesmo passo. Recusa a restrição que deixaria o desenho super-restrito ou sem solução, e então nada muda. Devolve o identificador da restrição e o que mudou.

Parâmetros

NomeTipoObrigatórioDescrição
constraintGeomSpecSimA restrição.
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": "horizontal",
        "parts": [
          {
            "id": "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"
          }
        ]
      },
      "operation": "cad.parametric.geometric"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.parametric.geometric(constraint="horizontal", parts=[{"id": "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"}])

LISP

LISP
(badbit-call "cad.parametric.geometric" '(("constraint" . "horizontal") ("parts" . ((("id" . "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"))))))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "constraint": "horizontal",
      "parts": [
        {
          "id": "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"
        }
      ]
    },
    "operation": "cad.parametric.geometric"
  }
}

Comandos que fazem o mesmo

GCCOINCIDENTGCCOLLINEARGCCONCENTRICGCEQUALGCFIXGCHORIZONTALGCPARALLELGCPERPENDICULARGCSMOOTHGCSYMMETRICGCTANGENTGCVERTICALGEOMCONSTRAINT

Esquema completo

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

Parâmetros (entrada)
JSON
{
  "$defs": {
    "GeomSpec": {
      "oneOf": [
        {
          "const": "coincident",
          "type": "string"
        },
        {
          "const": "collinear",
          "type": "string"
        },
        {
          "const": "concentric",
          "type": "string"
        },
        {
          "const": "fix",
          "type": "string"
        },
        {
          "const": "parallel",
          "type": "string"
        },
        {
          "const": "perpendicular",
          "type": "string"
        },
        {
          "const": "horizontal",
          "type": "string"
        },
        {
          "const": "vertical",
          "type": "string"
        },
        {
          "const": "tangent",
          "type": "string"
        },
        {
          "const": "smooth",
          "type": "string"
        },
        {
          "const": "symmetric",
          "type": "string"
        },
        {
          "const": "equal",
          "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": {
    "constraint": {
      "$ref": "#/$defs/GeomSpec",
      "description": "The constraint."
    },
    "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"
  ],
  "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