Skip to content
BadBit Documentation
Sign in Download the beta

BadBit CAD operations

cad.tools.cal

Calculates an expression (CAL, QUICKCALC).

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

Calculates expression with the CAL and QUICKCALC calculator: numbers, vectors [x,y,z], functions, units (2.5m becomes drawing units) and the QUICKCALC variables. Functions that pick points or objects on screen are not allowed. Returns value (a number) or vector and the text for the command line. Read only.

Parameters

NameTypeRequiredDescription
expressionstringYesThe value: a number or an expression with other parameters (for angles, degrees); in CAL, the expression to calculate.

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": {
        "expression": "(3+4)*2"
      },
      "operation": "cad.tools.cal"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.tools.cal(expression="(3+4)*2")

LISP

LISP
(badbit-call "cad.tools.cal" '(("expression" . "(3+4)*2")))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "expression": "(3+4)*2"
    },
    "operation": "cad.tools.cal"
  }
}

Commands that do the same

CALQUICKCALC

Full schema

JSON Schema 2020-12.

Parameters (input)
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "expression": {
      "description": "The value: a number or an expression with other parameters (for angles, degrees); in CAL, the expression to calculate.",
      "maxLength": 4096,
      "minLength": 1,
      "type": "string"
    }
  },
  "required": [
    "expression"
  ],
  "type": "object"
}
Result (output)
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "text": {
      "description": "The text (the one typed, or the result as text for the command line).",
      "type": "string"
    },
    "value": {
      "description": "The value: of the system variable (text as typed in SETVAR, or a number), of the measurement, of the calculation or of the filter test (number, angle in degrees, color, lineweight in mm, object type or text with * and ?).",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "vector": {
      "description": "The vector or point [x, y, z].",
      "items": {
        "format": "double",
        "type": "number"
      },
      "maxItems": 3,
      "minItems": 3,
      "type": [
        "array",
        "null"
      ]
    }
  },
  "required": [
    "text"
  ],
  "type": "object"
}
Search the documentation