BadBit CAD operations
cad.layer.create
Creates a layer.
- Program: BadBit CAD
- Type of action: Changes the drawing
- Changes the drawing
- Since version 2027.0.0-beta.6
Creates the layer name with the given properties (the rest as the layer defaults) and, with current, makes it the current layer. A linetype from the standard library (DASHED, HIDDEN, CENTER...) not yet in the drawing loads by itself. Fails if the name already exists.
- MCP tool
cad_layer_create
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": {
"color": 1,
"current": true,
"lineweight": 0.35,
"name": "Walls"
},
"name": "cad_layer_create"
}
}Python
Python
import badbit
result = badbit.cad.layer.create(color=1, current=True, lineweight=0.35, name="Walls")LISP
LISP
(badbit-call "cad.layer.create" '(("color" . 1) ("current" . T) ("lineweight" . 0.35) ("name" . "Walls")))JSON-RPC
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"color": 1,
"current": true,
"lineweight": 0.35,
"name": "Walls"
},
"operation": "cad.layer.create"
}
}Commands that do the same
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"
}