Skip to content
BadBit Documentation
Sign in Download the beta

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

NameTypeRequiredDescription
colorColor | nullNoColor: index 1 to 255 of the AutoCAD palette, bylayer, byblock, a name (red, yellow, green, cyan, blue, magenta, white) or #rrggbb.
currentboolean | nullNoCurrent layer: true makes it the layer where new objects are created; in results, whether it is.
frozenboolean | nullNoFrozen layer: not shown and not regenerated.
linetypestring | nullNoLinetype name (it must be loaded in the drawing), or bylayer.
lineweightLineweight | nullNoLineweight in millimeters (0.25, 0.35, 0.5…), or bylayer (on layers, default).
lockedboolean | nullNoLocked: for a layer, shown but its objects cannot be changed; for a layout viewport, its scale and view cannot change.
namestringYesName (of the layer, of the system variable or of the command, depending on the operation).
new_namestring | nullNoNew name of the layer.
onboolean | nullNoTurned on: the layer (off: its objects are not shown) or the layout viewport (off: it does not show the model).
plotboolean | nullNoThe layer is plotted.

Errors

CodeJSON-RPCMeaning
invalid_params-32602The parameters do not follow the schema or a rule of the operation.
conflict-32004The current state does not allow this now.
not_found-32001The 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"
}
Search the documentation