Operaciones de BadBit CAD
cad.image.attach
Enlaza una imagen o una página de PDF (IMAGEATTACH, PDFATTACH).
- Programa: BadBit CAD
- Tipo de acción: Actúa fuera del dibujo
- Modifica el dibujo
- Desde la versión 2027.0.0-beta.8
Enlaza la imagen (.png, .jpg, .tif, .bmp, .gif, .webp) o la página page del PDF (1 es la primera) del archivo path, con la esquina inferior izquierda en position, scale y rotation en grados, como IMAGEATTACH y PDFATTACH. Devuelve lo que cambió.
Parámetros
| Nombre | Tipo | Obligatorio | Descripción |
|---|---|---|---|
page | integer | null | No | La página: la configuración de página de la presentación, o la página del PDF (1 es la primera). |
path | string | Sí | La ruta absoluta del archivo (del dibujo, o el que la operación lee o graba). |
position | array<number> | Sí | Posición [x, y] de un punto o de un texto (el punto de inserción). |
rotation | number | null | No | Rotación en grados, antihorario. |
scale | number | null | No | La escala: de una inserción, la misma en X e Y; de una ventana gráfica, el denominador (50 es 1:50) o, en cad.viewport.modify, también el texto ("1:50", "2:1"). |
Errores
| Código | JSON-RPC | Qué significa |
|---|---|---|
invalid_params | -32602 | Los parámetros no siguen el esquema o una regla de la operación. |
not_found | -32001 | El objeto, la operación, el archivo o el nombre no existe. |
permission_denied | -32002 | La petición no se acepta (el detalle dice por qué). |
conflict | -32004 | El estado actual no lo permite ahora. |
failed | -32005 | La operación falló. |
Ejemplo
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"
}
}Comandos que hacen lo mismo
Esquema completo
JSON Schema 2020-12, con las descripciones en inglés.
Parámetros (entrada)
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"
}Resultado (salida)
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"
}