BadBit CAD operations
cad.block.define_edit
Edits a block definition (BEDIT with BSAVE, without the window).
- Program: BadBit CAD
- Type of action: Changes the drawing
- Deletes
- Since version 2027.0.0-beta.8
Changes the definition of the block name, as the block editor (BEDIT and BSAVE) and BATTMAN do, without the window: remove_items (indexes from cad.block.definition) and remove_tags go out, replace_items replaces items with drawing objects, add_ids come in (at the coordinates they are; erase_added erases them from the drawing), base changes the base point and attdefs changes the prompt, default and modes of attribute definitions. Every insert changes; sync_attributes (default yes) updates their attributes. The items of a dynamic block do not change here (the selection set indexes); the dynamic part changes with cad.block.parameter_add, cad.block.action_add and the other dynamic block operations. External references stay as they are. One undo step. Returns how many inserts changed and what changed.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
add_ids | array<string> | No | The objects that come in. |
attdefs | array<AttDefEdit> | No | The attribute definitions that change: tag, attribute_prompt, default_value, invisible and constant. |
base | array<number> | null | No | The base point [x, y] (in prompts to the person, the rubber-band line runs from it to the cursor). |
erase_added | boolean | No | Erases from the drawing the objects that went into the definition. |
name | string | Yes | Name (of the layer, of the system variable or of the command, depending on the operation). |
remove_items | array<integer> | No | The definition items that go out (indexes from cad.block.definition). |
remove_tags | array<string> | No | The attribute definitions that go out, by tag. |
replace_items | array<ReplaceItem> | No | Items replaced by drawing objects: item_index and id. |
sync_attributes | boolean | null | No | Updates the attributes of the inserts with the new definitions (default yes). |
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
{
"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
import badbit
result = badbit.cad.block.define_edit(add_ids=["0190f3a2b4c5d6e7f8091a2b3c4d5e6f"], erase_added=True, name="Door")LISP
(badbit-call "cad.block.define_edit" '(("add_ids" . ("0190f3a2b4c5d6e7f8091a2b3c4d5e6f")) ("erase_added" . T) ("name" . "Door")))JSON-RPC
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"add_ids": [
"0190f3a2b4c5d6e7f8091a2b3c4d5e6f"
],
"erase_added": true,
"name": "Door"
},
"operation": "cad.block.define_edit"
}
}Full schema
JSON Schema 2020-12.
Parameters (input)
{
"$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"
}Result (output)
{
"$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"
}