Operações do BadBit CAD
cad.layer.create
Cria uma camada.
- Programa: BadBit CAD
- Tipo de ação: Altera o desenho
- Altera o desenho
- Desde a versão 2027.0.0-beta.6
Cria a camada name com as propriedades dadas (o resto como o padrão da camada) e, com current, faz dela a camada atual. O tipo de linha da biblioteca padrão (DASHED, HIDDEN, CENTER...) que ainda não está no desenho é carregado sozinho. Falha se o nome já existe.
- Ferramenta MCP
cad_layer_create
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
color | Color | null | Não | Cor: índice 1 a 255 da paleta do AutoCAD, bylayer, byblock, um nome (red, yellow, green, cyan, blue, magenta, white) ou #rrggbb. |
current | boolean | null | Não | Camada atual: true faz dela a camada onde os objetos novos são criados; nos resultados, se ela é. |
frozen | boolean | null | Não | Camada congelada: não aparece nem é regenerada. |
linetype | string | null | Não | Nome do tipo de linha (tem de estar carregado no desenho), ou bylayer. |
lineweight | Lineweight | null | Não | Espessura em milímetros (0.25, 0.35, 0.5…), ou bylayer (nas camadas, default). |
locked | boolean | null | Não | Travada: na camada, mostrada mas sem mudar os objetos; na janela de vista, a escala e a vista não mudam. |
name | string | Sim | Nome (da camada, da variável de sistema ou do comando, conforme a operação). |
new_name | string | null | Não | Nome novo da camada. |
on | boolean | null | Não | Ligada: a camada (desligada, os objetos não aparecem) ou a janela de vista (desligada, não mostra o modelo). |
plot | boolean | null | Não | A camada sai na plotagem. |
Erros
| Código | JSON-RPC | O que significa |
|---|---|---|
invalid_params | -32602 | Os parâmetros não seguem o esquema ou uma regra da operação. |
conflict | -32004 | O estado atual não permite isso agora. |
not_found | -32001 | O objeto, a operação, o arquivo ou o nome não existe. |
Exemplo
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 fazem o mesmo
Esquema completo
JSON Schema 2020-12, com as descrições em 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 (saída)
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"
}