Pular para o conteúdo
BadBit Documentação
Entrar Baixar o beta

Operações do BadBit CAD

cad.image.attach

Anexa uma imagem ou uma página de PDF (IMAGEATTACH, PDFATTACH).

  • Programa: BadBit CAD
  • Tipo de ação: Age fora do desenho
  • Altera o desenho
  • Desde a versão 2027.0.0-beta.8

Anexa a imagem (.png, .jpg, .tif, .bmp, .gif, .webp) ou a página page do PDF (1 é a primeira) do arquivo path, com o canto de baixo à esquerda em position, scale e rotation em graus, como o IMAGEATTACH e o PDFATTACH. Devolve o que mudou.

Parâmetros

NomeTipoObrigatórioDescrição
pageinteger | nullNãoA página: a configuração de página do layout, ou a página do PDF (1 é a primeira).
pathstringSimO caminho absoluto do arquivo (do desenho, ou o que a operação lê ou grava).
positionarray<number>SimPosição [x, y] de um ponto ou de um texto (o ponto de inserção).
rotationnumber | nullNãoRotação em graus, anti-horário.
scalenumber | nullNãoA escala: de uma inserção, a mesma em X e Y; de uma janela de vista, o denominador (50 é 1:50) ou, no cad.viewport.modify, também o texto ("1:50", "2:1").

Erros

CódigoJSON-RPCO que significa
invalid_params-32602Os parâmetros não seguem o esquema ou uma regra da operação.
not_found-32001O objeto, a operação, o arquivo ou o nome não existe.
permission_denied-32002O pedido não é aceito (o detalhe diz por quê).
conflict-32004O estado atual não permite isso agora.
failed-32005A operação falhou.

Exemplo

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 fazem o mesmo

IMAGEATTACHPDFATTACH

Esquema completo

JSON Schema 2020-12, com as descrições em 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 (saída)
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"
}
Buscar na documentação