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

Operações do BadBit CAD

cad.block.visibility_state

Cria, renomeia, apaga, ordena ou escolhe estados de visibilidade de um bloco dinâmico (BVSTATE, -BVSTATE).

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

No bloco name (com o parâmetro de visibilidade), state_operation new cria state_name (que passa a ser o estado do bloco; new_state_mode hide_all, show_all ou keep_current, o padrão), rename troca o nome para new_state_name, delete apaga (o último não sai), set_current o torna o estado do bloco e move_up ou move_down muda a ordem, como o BVSTATE. O estado de cada inserção muda com cad.block.dynamic_set. Um passo do desfazer. Devolve o que mudou.

Parâmetros

NomeTipoObrigatórioDescrição
namestringSimNome (da camada, da variável de sistema ou do comando, conforme a operação).
new_state_modeDynNewStateMode | nullNãoO que o estado novo mostra: hide_all, show_all ou keep_current (o padrão: como o estado atual).
new_state_namestring | nullNãoO nome novo do estado.
state_namestringSimO nome do estado de visibilidade (no new, o do estado novo).
state_operationDynStateOperationSimO que fazer com o estado: new, rename, delete, set_current, move_up ou move_down.

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": {
        "name": "Door",
        "new_state_mode": "show_all",
        "state_name": "Closed",
        "state_operation": "new"
      },
      "operation": "cad.block.visibility_state"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.block.visibility_state(name="Door", new_state_mode="show_all", state_name="Closed", state_operation="new")

LISP

LISP
(badbit-call "cad.block.visibility_state" '(("name" . "Door") ("new_state_mode" . "show_all") ("state_name" . "Closed") ("state_operation" . "new")))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "name": "Door",
      "new_state_mode": "show_all",
      "state_name": "Closed",
      "state_operation": "new"
    },
    "operation": "cad.block.visibility_state"
  }
}

Comandos que fazem o mesmo

-BVSTATEBVSTATE

Esquema completo

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

Parâmetros (entrada)
JSON
{
  "$defs": {
    "DynNewStateMode": {
      "oneOf": [
        {
          "const": "hide_all",
          "type": "string"
        },
        {
          "const": "show_all",
          "type": "string"
        },
        {
          "const": "keep_current",
          "type": "string"
        }
      ]
    },
    "DynStateOperation": {
      "oneOf": [
        {
          "const": "new",
          "type": "string"
        },
        {
          "const": "rename",
          "type": "string"
        },
        {
          "const": "delete",
          "type": "string"
        },
        {
          "const": "set_current",
          "type": "string"
        },
        {
          "const": "move_up",
          "type": "string"
        },
        {
          "const": "move_down",
          "type": "string"
        }
      ]
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "name": {
      "description": "Name (of the layer, of the system variable or of the command, depending on the operation).",
      "type": "string"
    },
    "new_state_mode": {
      "anyOf": [
        {
          "$ref": "#/$defs/DynNewStateMode"
        },
        {
          "type": "null"
        }
      ],
      "description": "What the new state shows: hide_all, show_all or keep_current (the default: like the current state)."
    },
    "new_state_name": {
      "default": null,
      "description": "The new name of the state.",
      "type": [
        "string",
        "null"
      ]
    },
    "state_name": {
      "description": "The visibility state name (for new, the new state's).",
      "type": "string"
    },
    "state_operation": {
      "$ref": "#/$defs/DynStateOperation",
      "description": "What to do with the state: new, rename, delete, set_current, move_up or move_down."
    }
  },
  "required": [
    "name",
    "state_operation",
    "state_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"
    },
    "node": {
      "description": "The node number of the parameter or action (what the other dynamic block operations use).",
      "format": "uint32",
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    },
    "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