BadBit CAD operations
cad.layer.modify
Changes, renames or makes current a layer.
- Program: BadBit CAD
- Type of action: Changes the drawing
- Changes the drawing
- Since version 2027.0.0-beta.6
Changes the given properties of the layer name; new_name renames it (layer 0 cannot be renamed); current makes it the current layer.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
color | Color | null | No | Color: index 1 to 255 of the AutoCAD palette, bylayer, byblock, a name (red, yellow, green, cyan, blue, magenta, white) or #rrggbb. |
current | boolean | null | No | Current layer: true makes it the layer where new objects are created; in results, whether it is. |
frozen | boolean | null | No | Frozen layer: not shown and not regenerated. |
linetype | string | null | No | Linetype name (it must be loaded in the drawing), or bylayer. |
lineweight | Lineweight | null | No | Lineweight in millimeters (0.25, 0.35, 0.5…), or bylayer (on layers, default). |
locked | boolean | null | No | Locked: for a layer, shown but its objects cannot be changed; for a layout viewport, its scale and view cannot change. |
name | string | Yes | Name (of the layer, of the system variable or of the command, depending on the operation). |
new_name | string | null | No | New name of the layer. |
on | boolean | null | No | Turned on: the layer (off: its objects are not shown) or the layout viewport (off: it does not show the model). |
plot | boolean | null | No | The layer is plotted. |
Errors
| Code | JSON-RPC | Meaning |
|---|---|---|
invalid_params | -32602 | The parameters do not follow the schema or a rule of the operation. |
conflict | -32004 | The current state does not allow this now. |
not_found | -32001 | The object, operation, file or name does not exist. |
Example
MCP
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"arguments": {
"frozen": false,
"name": "Walls",
"new_name": "A-WALL"
},
"operation": "cad.layer.modify"
},
"name": "badbit_call_operation"
}
}Python
Python
import badbit
result = badbit.cad.layer.modify(frozen=False, name="Walls", new_name="A-WALL")LISP
LISP
(badbit-call "cad.layer.modify" '(("frozen" . nil) ("name" . "Walls") ("new_name" . "A-WALL")))JSON-RPC
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"frozen": false,
"name": "Walls",
"new_name": "A-WALL"
},
"operation": "cad.layer.modify"
}
}Commands that do the same
LAYFRZLAYLCKLAYMCURLAYOFFLAYULK
Full schema
JSON Schema 2020-12.
Parameters (input)
JSON
{
"$defs": {
"Color": {
"anyOf": [
{
"format": "uint8",
"maximum": 255,
"minimum": 0,
"type": "integer"
},
{
"type": "string"
}
]
},
"Lineweight": {
"anyOf": [
{
"format": "double",
"type": "number"
},
{
"type": "string"
}
]
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"color": {
"anyOf": [
{
"$ref": "#/$defs/Color"
},
{
"type": "null"
}
],
"default": null,
"description": "Color: index 1 to 255 of the AutoCAD palette, bylayer, byblock, a name (red, yellow, green, cyan, blue, magenta, white) or #rrggbb."
},
"current": {
"default": null,
"description": "Current layer: true makes it the layer where new objects are created; in results, whether it is.",
"type": [
"boolean",
"null"
]
},
"frozen": {
"default": null,
"description": "Frozen layer: not shown and not regenerated.",
"type": [
"boolean",
"null"
]
},
"linetype": {
"default": null,
"description": "Linetype name (it must be loaded in the drawing), or bylayer.",
"type": [
"string",
"null"
]
},
"lineweight": {
"anyOf": [
{
"$ref": "#/$defs/Lineweight"
},
{
"type": "null"
}
],
"default": null,
"description": "Lineweight in millimeters (0.25, 0.35, 0.5…), or bylayer (on layers, default)."
},
"locked": {
"default": null,
"description": "Locked: for a layer, shown but its objects cannot be changed; for a layout viewport, its scale and view cannot change.",
"type": [
"boolean",
"null"
]
},
"name": {
"description": "Name (of the layer, of the system variable or of the command, depending on the operation).",
"maxLength": 255,
"minLength": 1,
"type": "string"
},
"new_name": {
"default": null,
"description": "New name of the layer.",
"maxLength": 255,
"minLength": 1,
"type": [
"string",
"null"
]
},
"on": {
"default": null,
"description": "Turned on: the layer (off: its objects are not shown) or the layout viewport (off: it does not show the model).",
"type": [
"boolean",
"null"
]
},
"plot": {
"default": null,
"description": "The layer is plotted.",
"type": [
"boolean",
"null"
]
}
},
"required": [
"name"
],
"type": "object"
}Result (output)
JSON
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"name": {
"description": "Name (of the layer, of the system variable or of the command, depending on the operation).",
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
}