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
| Nombre | Tipo | Obligatorio | Descripción |
|---|---|---|---|
attribute_prompt | string | No | La pregunta que aparece al insertar el bloque. |
default_value | string | No | El valor predeterminado del atributo. |
height | number | null | No | La 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. |
justify | TextJustify | null | No | La justificación del texto: L, C, R, M, TL, TC, TR, ML, MC, MR, BL, BC o BR. |
modes | array<AttMode> | null | No | Los modos del atributo: invisible, constant, verify, preset, lock_position y multiline. |
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. |
style | string | null | No | Nombre del estilo de texto (debe existir en el dibujo). |
tag | string | Sí | La etiqueta del atributo (sin espacios). |
width | number | null | No | El ancho: de la imagen, en píxeles (64 a 2048, por defecto 1024); de la vista guardada, en unidades del dibujo. |
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. |
conflict | -32004 | El estado actual no lo permite ahora. |
failed | -32005 | La operación falló. |
Ejemplo
MCP
{
"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
import badbit
result = badbit.cad.draw.attdef(attribute_prompt="Room name", default_value="Kitchen", height=2.5, position=[0, 0], tag="ROOM")LISP
(badbit-call "cad.draw.attdef" '(("attribute_prompt" . "Room name") ("default_value" . "Kitchen") ("height" . 2.5) ("position" . (0 0)) ("tag" . "ROOM")))JSON-RPC
{
"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
Esquema completo
JSON Schema 2020-12, con las descripciones en inglés.
Parámetros (entrada)
{
"$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)
{
"$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"
}