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

Operações do BadBit CAD

cad.draw.attdef

Cria uma definição de atributo (-ATTDEF).

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

Cria a definição de atributo tag (sem espaços) em position, com a pergunta attribute_prompt e o valor padrão default_value, como o -ATTDEF: height, rotation em graus, style (estilo de texto), justify (L, C, R, M, TL, TC, TR, ML, MC, MR, BL, BC ou BR) e modes (invisible, constant, verify, preset, lock_position, multiline); o que não vier fica como o comando lembra. Ela entra num bloco com cad.draw.block. Devolve o que mudou. No papel (um layout à vista, fora das janelas de vista), as coordenadas e as medidas são em mm; os ângulos e os fatores de escala não mudam.

Parâmetros

NomeTipoObrigatórioDescrição
attribute_promptstringNãoA pergunta que aparece ao inserir o bloco.
default_valuestringNãoO valor padrão do atributo.
heightnumber | nullNãoA altura do texto; no zoom, a altura visível; nas imagens, a altura em pixels; na vista nomeada, em unidades do desenho; na janela de vista, a altura do modelo que ela mostra, em unidades do desenho.
justifyTextJustify | nullNãoA justificação do texto: L, C, R, M, TL, TC, TR, ML, MC, MR, BL, BC ou BR.
modesarray<AttMode> | nullNãoOs modos do atributo: invisible, constant, verify, preset, lock_position e multiline.
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.
stylestring | nullNãoNome do estilo de texto (tem de existir no desenho).
tagstringSimO rótulo do atributo (sem espaços).
widthnumber | nullNãoA largura: da imagem, em pixels (64 a 2048, padrão 1024); da vista nomeada, em unidades do desenho.

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.
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": {
        "attribute_prompt": "Room name",
        "default_value": "Kitchen",
        "height": 2.5,
        "position": [
          0,
          0
        ],
        "tag": "ROOM"
      },
      "operation": "cad.draw.attdef"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.draw.attdef(attribute_prompt="Room name", default_value="Kitchen", height=2.5, position=[0, 0], tag="ROOM")

LISP

LISP
(badbit-call "cad.draw.attdef" '(("attribute_prompt" . "Room name") ("default_value" . "Kitchen") ("height" . 2.5) ("position" . (0 0)) ("tag" . "ROOM")))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "attribute_prompt": "Room name",
      "default_value": "Kitchen",
      "height": 2.5,
      "position": [
        0,
        0
      ],
      "tag": "ROOM"
    },
    "operation": "cad.draw.attdef"
  }
}

Comandos que fazem o mesmo

-ATTDEFATTDEF

Esquema completo

JSON Schema 2020-12, com as descrições em inglês.

Parâmetros (entrada)
JSON
{
  "$defs": {
    "AttMode": {
      "oneOf": [
        {
          "const": "invisible",
          "type": "string"
        },
        {
          "const": "constant",
          "type": "string"
        },
        {
          "const": "verify",
          "type": "string"
        },
        {
          "const": "preset",
          "type": "string"
        },
        {
          "const": "lock_position",
          "type": "string"
        },
        {
          "const": "multiline",
          "type": "string"
        }
      ]
    },
    "TextJustify": {
      "oneOf": [
        {
          "const": "L",
          "type": "string"
        },
        {
          "const": "C",
          "type": "string"
        },
        {
          "const": "R",
          "type": "string"
        },
        {
          "const": "M",
          "type": "string"
        },
        {
          "const": "TL",
          "type": "string"
        },
        {
          "const": "TC",
          "type": "string"
        },
        {
          "const": "TR",
          "type": "string"
        },
        {
          "const": "ML",
          "type": "string"
        },
        {
          "const": "MC",
          "type": "string"
        },
        {
          "const": "MR",
          "type": "string"
        },
        {
          "const": "BL",
          "type": "string"
        },
        {
          "const": "BC",
          "type": "string"
        },
        {
          "const": "BR",
          "type": "string"
        }
      ]
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "attribute_prompt": {
      "default": "",
      "description": "The prompt shown when the block is inserted.",
      "type": "string"
    },
    "default_value": {
      "default": "",
      "description": "The default value of the attribute.",
      "type": "string"
    },
    "height": {
      "default": null,
      "description": "Text height; in zoom, the visible height; in images, the height in pixels; in a named view, in drawing units; in a layout viewport, the height of the model it shows, in drawing units.",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "justify": {
      "anyOf": [
        {
          "$ref": "#/$defs/TextJustify"
        },
        {
          "type": "null"
        }
      ],
      "description": "The text justification: L, C, R, M, TL, TC, TR, ML, MC, MR, BL, BC or BR."
    },
    "modes": {
      "description": "The attribute modes: invisible, constant, verify, preset, lock_position and multiline.",
      "items": {
        "$ref": "#/$defs/AttMode"
      },
      "maxItems": 6,
      "type": [
        "array",
        "null"
      ]
    },
    "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"
      ]
    },
    "style": {
      "default": null,
      "description": "Text style name (it must exist in the drawing).",
      "type": [
        "string",
        "null"
      ]
    },
    "tag": {
      "description": "The attribute tag (no spaces).",
      "maxLength": 255,
      "minLength": 1,
      "type": "string"
    },
    "width": {
      "default": null,
      "description": "The width: of an image, in pixels (64 to 2048, default 1024); of a named view, in drawing units.",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    }
  },
  "required": [
    "tag",
    "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"
    },
    "skipped_locked": {
      "description": "Objects left as they were because they are on locked layers.",
      "format": "uint",
      "minimum": 0,
      "type": "integer"
    },
    "truncated": {
      "description": "The lists were cut at the limit.",
      "type": "boolean"
    }
  },
  "required": [
    "created",
    "modified",
    "deleted",
    "document_changed",
    "truncated"
  ],
  "type": "object"
}
Buscar na documentação