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

Operaciones de BadBit CAD

cad.block.define_edit

Edita la definición de un bloque (BEDIT con BSAVE, sin ventana).

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

Cambia la definición del bloque name, como hacen el editor de bloques (BEDIT y BSAVE) y BATTMAN, sin la ventana: salen remove_items (índices de cad.block.definition) y remove_tags, replace_items cambia elementos por objetos del dibujo, entran add_ids (en las coordenadas en que están; erase_added los borra del dibujo), base cambia el punto base y attdefs cambia la pregunta, el valor predeterminado y los modos de las definiciones de atributo. Todas las inserciones cambian; sync_attributes (predeterminado sí) actualiza sus atributos. Los elementos de un bloque dinámico no cambian aquí (los índices de los conjuntos de selección); la parte dinámica cambia con cad.block.parameter_add, cad.block.action_add y las otras operaciones de bloque dinámico. Las referencias externas quedan como están. Un paso de deshacer. Devuelve cuántas inserciones cambiaron y lo que cambió.

Parámetros

NombreTipoObligatorioDescripción
add_idsarray<string>NoLos objetos que entran.
attdefsarray<AttDefEdit>NoLas definiciones de atributo que cambian: tag, attribute_prompt, default_value, invisible y constant.
basearray<number> | nullNoEl punto base [x, y] (en las preguntas a la persona, la línea elástica sale de él hasta el cursor).
erase_addedbooleanNoBorra del dibujo los objetos que entraron en la definición.
namestringSíNombre (de la capa, de la variable de sistema o del comando, según la operación).
remove_itemsarray<integer>NoLos elementos de la definición que salen (los índices de cad.block.definition).
remove_tagsarray<string>NoLas definiciones de atributo que salen, por la etiqueta.
replace_itemsarray<ReplaceItem>NoElementos cambiados por objetos del dibujo: item_index e id.
sync_attributesboolean | nullNoActualiza los atributos de las inserciones con las definiciones nuevas (predeterminado sí).

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": {
        "add_ids": [
          "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"
        ],
        "erase_added": true,
        "name": "Door"
      },
      "operation": "cad.block.define_edit"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.block.define_edit(add_ids=["0190f3a2b4c5d6e7f8091a2b3c4d5e6f"], erase_added=True, name="Door")

LISP

LISP
(badbit-call "cad.block.define_edit" '(("add_ids" . ("0190f3a2b4c5d6e7f8091a2b3c4d5e6f")) ("erase_added" . T) ("name" . "Door")))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "add_ids": [
        "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"
      ],
      "erase_added": true,
      "name": "Door"
    },
    "operation": "cad.block.define_edit"
  }
}

Esquema completo

JSON Schema 2020-12, con las descripciones en inglés.

Parámetros (entrada)
JSON
{
  "$defs": {
    "AttDefEdit": {
      "additionalProperties": false,
      "properties": {
        "attribute_prompt": {
          "default": null,
          "description": "The prompt shown when the block is inserted.",
          "type": [
            "string",
            "null"
          ]
        },
        "constant": {
          "default": null,
          "description": "Constant attribute.",
          "type": [
            "boolean",
            "null"
          ]
        },
        "default_value": {
          "default": null,
          "description": "The default value of the attribute.",
          "type": [
            "string",
            "null"
          ]
        },
        "invisible": {
          "default": null,
          "description": "Invisible attribute.",
          "type": [
            "boolean",
            "null"
          ]
        },
        "tag": {
          "description": "The attribute tag (no spaces).",
          "type": "string"
        }
      },
      "required": [
        "tag"
      ],
      "type": "object"
    },
    "ReplaceItem": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "Object identifier (32 hexadecimal digits), or command identifier in the command list.",
          "type": "string"
        },
        "item_index": {
          "description": "The index of the item in the definition (see cad.block.definition).",
          "format": "uint32",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "item_index",
        "id"
      ],
      "type": "object"
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "add_ids": {
      "default": [],
      "description": "The objects that come in.",
      "items": {
        "type": "string"
      },
      "maxItems": 200000,
      "type": "array"
    },
    "attdefs": {
      "description": "The attribute definitions that change: tag, attribute_prompt, default_value, invisible and constant.",
      "items": {
        "$ref": "#/$defs/AttDefEdit"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "base": {
      "default": null,
      "description": "The base point [x, y] (in prompts to the person, the rubber-band line runs from it to the cursor).",
      "items": {
        "format": "double",
        "type": "number"
      },
      "maxItems": 2,
      "minItems": 2,
      "type": [
        "array",
        "null"
      ]
    },
    "erase_added": {
      "default": false,
      "description": "Erases from the drawing the objects that went into the definition.",
      "type": "boolean"
    },
    "name": {
      "description": "Name (of the layer, of the system variable or of the command, depending on the operation).",
      "type": "string"
    },
    "remove_items": {
      "default": [],
      "description": "The definition items that go out (indexes from cad.block.definition).",
      "items": {
        "format": "uint32",
        "minimum": 0,
        "type": "integer"
      },
      "maxItems": 100000,
      "type": "array"
    },
    "remove_tags": {
      "default": [],
      "description": "The attribute definitions that go out, by tag.",
      "items": {
        "type": "string"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "replace_items": {
      "description": "Items replaced by drawing objects: item_index and id.",
      "items": {
        "$ref": "#/$defs/ReplaceItem"
      },
      "maxItems": 100000,
      "type": "array"
    },
    "sync_attributes": {
      "default": null,
      "description": "Updates the attributes of the inserts with the new definitions (default yes).",
      "type": [
        "boolean",
        "null"
      ]
    }
  },
  "required": [
    "name"
  ],
  "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"
    },
    "inserts_changed": {
      "description": "How many inserts of the block changed.",
      "format": "uint",
      "minimum": 0,
      "type": "integer"
    },
    "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": [
    "inserts_changed",
    "created",
    "modified",
    "deleted",
    "document_changed",
    "truncated"
  ],
  "type": "object"
}
Buscar en la documentación