Skip to content
BadBit Documentation
Sign in Download the beta

BadBit CAD operations

cad.parametric.dimensional

Applies a dimensional constraint (DIMCONSTRAINT, DCLINEAR, DCALIGNED, DCRADIUS...).

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

Creates the dimensional constraint constraint (linear, horizontal, vertical, aligned, angular, radius, diameter) on the parts parts (two points, a line, two lines or an arc), with the dimension line at dim_line_point. expression gives the value (a number or an expression with other parameters; for angles, degrees; without it, the current measurement) and the solver adjusts the geometry; param_name gives the name (without it, d1, ang1, rad1, dia1). With as_reference, it becomes a reference dimension (it only measures). Returns the identifier and what changed.

Parameters

NameTypeRequiredDescription
as_referencebooleanNoCreates it as a reference dimension (it measures, it does not drive the geometry).
constraintDimSpecYesThe constraint.
dim_line_pointarray<number>YesA point [x, y] the dimension line (or arc) passes through; in radial and ordinate dimensions, where the text goes.
expressionstring | nullNoThe value: a number or an expression with other parameters (for angles, degrees); in CAL, the expression to calculate.
param_namestring | nullNoThe parameter name (data from the drawing, in results).
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": "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"
  }
}

Commands that do the same

DCALIGNEDDCANGULARDCDIAMETERDCHORIZONTALDCLINEARDCRADIUSDCVERTICALDIMCONSTRAINT

Full schema

JSON Schema 2020-12.

Parameters (input)
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"
}
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