Skip to content
BadBit Documentation
Sign in Download the beta

BadBit CAD operations

cad.parametric.geometric

Applies a geometric constraint (GEOMCONSTRAINT, GCHORIZONTAL, GCPARALLEL...).

  • Program: BadBit CAD
  • Type of action: Changes the drawing
  • Changes the drawing
  • Since version 2027.0.0-beta.8

Applies the constraint constraint (coincident, collinear, concentric, fix, parallel, perpendicular, horizontal, vertical, tangent, smooth, symmetric, equal) to the parts parts (each with id and part: whole, start, end, mid, center, {"vertex_index": n}...), in the order of the command's prompts: the first stays, the second adjusts. The solver moves the geometry in the same step. It refuses a constraint that would over-constrain the drawing or leave it without a solution, and then nothing changes. Returns the constraint identifier and what changed.

Parameters

NameTypeRequiredDescription
constraintGeomSpecYesThe constraint.
partsarray<Part>YesThe parts, each with id and part (whole, start, end, mid, center, {"vertex_index": n}, {"segment": n}, {"segment_mid": n}, major_axis, minor_axis).

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.
conflict-32004The current state does not allow this now.
failed-32005The operation failed.

Example

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

Commands that do the same

GCCOINCIDENTGCCOLLINEARGCCONCENTRICGCEQUALGCFIXGCHORIZONTALGCPARALLELGCPERPENDICULARGCSMOOTHGCSYMMETRICGCTANGENTGCVERTICALGEOMCONSTRAINT

Full schema

JSON Schema 2020-12.

Parameters (input)
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"
}
Result (output)
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"
}
Search the documentation