Skip to content
BadBit Documentation
Sign in Download the beta

BadBit CAD operations

cad.draw.insert

Inserts a block (INSERT) at a point.

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

Inserts the block name (it must exist in the drawing; list them with cad.block.list) at position, with scale (the same in X and Y, default 1) and rotation in degrees, on layer or on the current layer. Attributes get their default values. Returns the identifier. In paper space (a layout on screen, outside the viewports), the coordinates and the measures are in mm; angles and scale factors do not change.

Parameters

NameTypeRequiredDescription
layerstring | nullNoLayer name.
namestringYesName (of the layer, of the system variable or of the command, depending on the operation).
positionarray<number>YesPosition [x, y] of a point or of a text (the insertion point).
rotationnumber | nullNoRotation in degrees, counterclockwise.
scalenumber | nullNoThe scale: of an insertion, the same in X and Y; of a layout viewport, the denominator (50 is 1:50) or, in cad.viewport.modify, also the text ("1:50", "2:1").

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": {
        "name": "Door",
        "position": [
          100,
          0
        ],
        "rotation": 90
      },
      "operation": "cad.draw.insert"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.draw.insert(name="Door", position=[100, 0], rotation=90)

LISP

LISP
(badbit-call "cad.draw.insert" '(("name" . "Door") ("position" . (100 0)) ("rotation" . 90)))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "name": "Door",
      "position": [
        100,
        0
      ],
      "rotation": 90
    },
    "operation": "cad.draw.insert"
  }
}

Commands that do the same

INSERT

Full schema

JSON Schema 2020-12.

Parameters (input)
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "layer": {
      "default": null,
      "description": "Layer name.",
      "type": [
        "string",
        "null"
      ]
    },
    "name": {
      "description": "Name (of the layer, of the system variable or of the command, depending on the operation).",
      "type": "string"
    },
    "position": {
      "description": "Position [x, y] of a point or of a text (the insertion point).",
      "items": {
        "format": "double",
        "type": "number"
      },
      "maxItems": 2,
      "minItems": 2,
      "type": "array"
    },
    "rotation": {
      "default": null,
      "description": "Rotation in degrees, counterclockwise.",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "scale": {
      "default": null,
      "description": "The scale: of an insertion, the same in X and Y; of a layout viewport, the denominator (50 is 1:50) or, in cad.viewport.modify, also the text (\"1:50\", \"2:1\").",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    }
  },
  "required": [
    "name",
    "position"
  ],
  "type": "object"
}
Result (output)
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "ids": {
      "description": "Object identifiers (32 hexadecimal digits each).",
      "items": {
        "type": "string"
      },
      "type": "array"
    }
  },
  "required": [
    "ids"
  ],
  "type": "object"
}
Search the documentation