Operaciones de BadBit CAD
cad.layer.create
Crea una capa.
- Programa: BadBit CAD
- Tipo de acción: Cambia el dibujo
- Modifica el dibujo
- Desde la versión 2027.0.0-beta.6
Crea la capa name con las propiedades dadas (el resto como el valor por defecto de la capa) y, con current, la hace la capa actual. El tipo de línea de la biblioteca estándar (DASHED, HIDDEN, CENTER...) que aún no está en el dibujo se carga solo. Falla si el nombre ya existe.
- Herramienta MCP
cad_layer_create
Parámetros
| Nombre | Tipo | Obligatorio | Descripción |
|---|---|---|---|
color | Color | null | No | Color: índice 1 a 255 de la paleta de AutoCAD, bylayer, byblock, un nombre (red, yellow, green, cyan, blue, magenta, white) o #rrggbb. |
current | boolean | null | No | Capa actual: true la hace la capa donde se crean los objetos nuevos; en los resultados, si lo es. |
frozen | boolean | null | No | Capa inutilizada: no se muestra ni se regenera. |
linetype | string | null | No | Nombre del tipo de línea (debe estar cargado en el dibujo), o bylayer. |
lineweight | Lineweight | null | No | Grosor en milímetros (0.25, 0.35, 0.5…), o bylayer (en las capas, default). |
locked | boolean | null | No | Bloqueada: en la capa, se muestra pero sus objetos no cambian; en la ventana gráfica, la escala y la vista no cambian. |
name | string | Sí | Nombre (de la capa, de la variable de sistema o del comando, según la operación). |
new_name | string | null | No | Nombre nuevo de la capa. |
on | boolean | null | No | Activada: la capa (desactivada, sus objetos no se muestran) o la ventana gráfica (desactivada, no muestra el modelo). |
plot | boolean | null | No | La capa sale en el trazado. |
Errores
| Código | JSON-RPC | Qué significa |
|---|---|---|
invalid_params | -32602 | Los parámetros no siguen el esquema o una regla de la operación. |
conflict | -32004 | El estado actual no lo permite ahora. |
not_found | -32001 | El objeto, la operación, el archivo o el nombre no existe. |
Ejemplo
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"
}
}Comandos que hacen lo mismo
Esquema completo
JSON Schema 2020-12, con las descripciones en inglés.
Parámetros (entrada)
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"
}Resultado (salida)
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"
}