Saltar al contenido
BadBit Documentación
Iniciar sesión Descargar la beta

Operaciones de BadBit CAD

cad.draw.attdef

Crea una definición de atributo (-ATTDEF).

  • Programa: BadBit CAD
  • Tipo de acción: Cambia el dibujo
  • Modifica el dibujo
  • Desde la versión 2027.0.0-beta.8

Crea la definición de atributo tag (sin espacios) en position, con la pregunta attribute_prompt y el valor predeterminado default_value, como -ATTDEF: height, rotation en grados, style (estilo de texto), justify (L, C, R, M, TL, TC, TR, ML, MC, MR, BL, BC o BR) y modes (invisible, constant, verify, preset, lock_position, multiline); lo que no venga queda como el comando lo recuerda. Entra en un bloque con cad.draw.block. Devuelve lo que cambió. En el papel (una presentación a la vista, fuera de las ventanas gráficas), las coordenadas y las medidas son en mm; los ángulos y los factores de escala no cambian.

Parámetros

NombreTipoObligatorioDescripción
attribute_promptstringNoLa pregunta que aparece al insertar el bloque.
default_valuestringNoEl valor predeterminado del atributo.
heightnumber | nullNoLa altura del texto; en el zoom, la altura visible; en las imágenes, la altura en píxeles; en la vista guardada, en unidades del dibujo; en la ventana gráfica, la altura del modelo que muestra, en unidades del dibujo.
justifyTextJustify | nullNoLa justificación del texto: L, C, R, M, TL, TC, TR, ML, MC, MR, BL, BC o BR.
modesarray<AttMode> | nullNoLos modos del atributo: invisible, constant, verify, preset, lock_position y multiline.
positionarray<number>SíPosición [x, y] de un punto o de un texto (el punto de inserción).
rotationnumber | nullNoRotación en grados, antihorario.
stylestring | nullNoNombre del estilo de texto (debe existir en el dibujo).
tagstringSíLa etiqueta del atributo (sin espacios).
widthnumber | nullNoEl ancho: de la imagen, en píxeles (64 a 2048, por defecto 1024); de la vista guardada, en unidades del dibujo.

Errores

CódigoJSON-RPCQué significa
invalid_params-32602Los parámetros no siguen el esquema o una regla de la operación.
not_found-32001El objeto, la operación, el archivo o el nombre no existe.
conflict-32004El estado actual no lo permite ahora.
failed-32005La operación falló.

Ejemplo

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 hacen lo mismo

-ATTDEFATTDEF

Esquema completo

JSON Schema 2020-12, con las descripciones en 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 (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"
    },
    "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 en la documentación