BadBit CAD operations
cad.image.attach
Attaches an image or a PDF page (IMAGEATTACH, PDFATTACH).
- Program: BadBit CAD
- Type of action: Acts outside the drawing
- Changes the drawing
- Since version 2027.0.0-beta.8
Attaches the image (.png, .jpg, .tif, .bmp, .gif, .webp) or page page of the PDF (1 is the first) from file path, with the lower left corner at position, scale and rotation in degrees, like IMAGEATTACH and PDFATTACH. Returns what changed.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
page | integer | null | No | The page: the page setup of a layout, or the PDF page (1 is the first). |
path | string | Yes | The absolute path of the file (of the drawing, or the one the operation reads or writes). |
position | array<number> | Yes | Position [x, y] of a point or of a text (the insertion point). |
rotation | number | null | No | Rotation in degrees, counterclockwise. |
scale | number | null | No | 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"). |
Errors
| Code | JSON-RPC | Meaning |
|---|---|---|
invalid_params | -32602 | The parameters do not follow the schema or a rule of the operation. |
not_found | -32001 | The object, operation, file or name does not exist. |
permission_denied | -32002 | The request is not accepted (the detail says why). |
conflict | -32004 | The current state does not allow this now. |
failed | -32005 | The operation failed. |
Example
MCP
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"arguments": {
"path": "/Users/ana/Documents/BadBit/foto.png",
"position": [
0,
0
],
"scale": 10
},
"operation": "cad.image.attach"
},
"name": "badbit_call_operation"
}
}Python
Python
import badbit
result = badbit.cad.image.attach(path="/Users/ana/Documents/BadBit/foto.png", position=[0, 0], scale=10)LISP
LISP
(badbit-call "cad.image.attach" '(("path" . "/Users/ana/Documents/BadBit/foto.png") ("position" . (0 0)) ("scale" . 10)))JSON-RPC
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"path": "/Users/ana/Documents/BadBit/foto.png",
"position": [
0,
0
],
"scale": 10
},
"operation": "cad.image.attach"
}
}Commands that do the same
Full schema
JSON Schema 2020-12.
Parameters (input)
JSON
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"page": {
"default": null,
"description": "The page: the page setup of a layout, or the PDF page (1 is the first).",
"format": "uint",
"maximum": 100000,
"minimum": 1,
"type": [
"integer",
"null"
]
},
"path": {
"description": "The absolute path of the file (of the drawing, or the one the operation reads or writes).",
"maxLength": 4096,
"minLength": 1,
"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": [
"path",
"position"
],
"type": "object"
}Result (output)
JSON
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"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"
},
"truncated": {
"description": "The lists were cut at the limit.",
"type": "boolean"
}
},
"required": [
"created",
"modified",
"deleted",
"document_changed",
"truncated"
],
"type": "object"
}