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

Operações do BadBit CAD

cad.block.define_edit

Edita a definição de um bloco (o BEDIT com o BSAVE, sem janela).

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

Muda a definição do bloco name, como o editor de blocos (BEDIT e BSAVE) e o BATTMAN fazem, sem a janela: saem remove_items (índices de cad.block.definition) e remove_tags, replace_items troca itens por objetos do desenho, entram add_ids (nas coordenadas em que estão; erase_added os apaga do desenho), base muda o ponto base e attdefs muda a pergunta, o padrão e os modos das definições de atributo. Todas as inserções mudam; sync_attributes (padrão sim) atualiza os atributos delas. Os itens de um bloco dinâmico não mudam aqui (os índices dos conjuntos de seleção); a parte dinâmica muda com cad.block.parameter_add, cad.block.action_add e as outras operações de bloco dinâmico. As referências externas ficam como estão. Um passo do desfazer. Devolve quantas inserções mudaram e o que mudou.

Parâmetros

NomeTipoObrigatórioDescrição
add_idsarray<string>NãoOs objetos que entram.
attdefsarray<AttDefEdit>NãoAs definições de atributo que mudam: tag, attribute_prompt, default_value, invisible e constant.
basearray<number> | nullNãoO ponto base [x, y] (nas perguntas à pessoa, a linha elástica sai dele até o cursor).
erase_addedbooleanNãoApaga do desenho os objetos que entraram na definição.
namestringSimNome (da camada, da variável de sistema ou do comando, conforme a operação).
remove_itemsarray<integer>NãoOs itens da definição que saem (os índices de cad.block.definition).
remove_tagsarray<string>NãoAs definições de atributo que saem, pelo rótulo.
replace_itemsarray<ReplaceItem>NãoItens trocados por objetos do desenho: item_index e id.
sync_attributesboolean | nullNãoAtualiza os atributos das inserções com as definições novas (padrão sim).

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": {
        "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, com as descrições em 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 (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"
    },
    "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 na documentação