BadBit CAD operations
cad.block.visibility_state
Creates, renames, deletes, orders or chooses visibility states of a dynamic block (BVSTATE, -BVSTATE).
- Program: BadBit CAD
- Type of action: Changes the drawing
- Changes the drawing
- Since version 2027.0.0-beta.8
In the block name (with the visibility parameter), state_operation new creates state_name (which becomes the block state; new_state_mode hide_all, show_all or keep_current, the default), rename changes its name to new_state_name, delete deletes it (the last one stays), set_current makes it the block state and move_up or move_down changes the order, like BVSTATE. The state of each insert changes with cad.block.dynamic_set. One undo step. Returns what changed.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Name (of the layer, of the system variable or of the command, depending on the operation). |
new_state_mode | DynNewStateMode | null | No | What the new state shows: hide_all, show_all or keep_current (the default: like the current state). |
new_state_name | string | null | No | The new name of the state. |
state_name | string | Yes | The visibility state name (for new, the new state's). |
state_operation | DynStateOperation | Yes | What to do with the state: new, rename, delete, set_current, move_up or move_down. |
Errors
| Code | JSON-RPC | Meaning |
|---|---|---|
invalid_params | -32602 | The parameters do not follow the schema or a rule of the operation. |
not_found | -32001 | The object, operation, file or name does not exist. |
conflict | -32004 | The current state does not allow this now. |
failed | -32005 | The operation failed. |
Example
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"
}
}Commands that do the same
Full schema
JSON Schema 2020-12.
Parameters (input)
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"
}Result (output)
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"
}