BadBit CAD operations
cad.layout.viewport
Changes the scale, center, lock or on state of layout viewports.
- Program: BadBit CAD
- Type of action: Changes the drawing
- Changes the drawing
- Since version 2027.0.0-beta.8
On layout viewports ids: scale (the denominator: 50 is 1:50), view_center (the model point at the center), locked (MVIEW Lock) and on (MVIEW ON or OFF). One undo step. Returns what changed. For one viewport, with the scale as text or by height: cad.viewport.modify.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
ids | array<string> | Yes | Object identifiers (32 hexadecimal digits each). |
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. |
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). |
scale | number | null | No | The scale: of an insertion, the same in X and Y; of a layout viewport, the denominator (50 is 1:50) or, in cad.viewport.modify, also the text ("1:50", "2:1"). |
view_center | array<number> | null | No | The model point at the center of the layout viewport. |
Errors
| Code | JSON-RPC | Meaning |
|---|---|---|
invalid_params | -32602 | The parameters do not follow the schema or a rule of the operation. |
not_found | -32001 | The object, operation, file or name does not exist. |
conflict | -32004 | The current state does not allow this now. |
failed | -32005 | The operation failed. |
Example
MCP
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"arguments": {
"ids": [
"0190f3a2b4c5d6e7f8091a2b3c4d5e6f"
],
"scale": 100,
"view_center": [
5000,
3000
]
},
"operation": "cad.layout.viewport"
},
"name": "badbit_call_operation"
}
}Python
Python
import badbit
result = badbit.cad.layout.viewport(ids=["0190f3a2b4c5d6e7f8091a2b3c4d5e6f"], scale=100, view_center=[5000, 3000])LISP
LISP
(badbit-call "cad.layout.viewport" '(("ids" . ("0190f3a2b4c5d6e7f8091a2b3c4d5e6f")) ("scale" . 100) ("view_center" . (5000 3000))))JSON-RPC
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"ids": [
"0190f3a2b4c5d6e7f8091a2b3c4d5e6f"
],
"scale": 100,
"view_center": [
5000,
3000
]
},
"operation": "cad.layout.viewport"
}
}Full schema
JSON Schema 2020-12.
Parameters (input)
JSON
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"ids": {
"description": "Object identifiers (32 hexadecimal digits each).",
"items": {
"type": "string"
},
"maxItems": 10000,
"minItems": 1,
"type": "array"
},
"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"
]
},
"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"
]
},
"scale": {
"default": null,
"description": "The scale: of an insertion, the same in X and Y; of a layout viewport, the denominator (50 is 1:50) or, in cad.viewport.modify, also the text (\"1:50\", \"2:1\").",
"format": "double",
"type": [
"number",
"null"
]
},
"view_center": {
"default": null,
"description": "The model point at the center of the layout viewport.",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": [
"array",
"null"
]
}
},
"required": [
"ids"
],
"type": "object"
}Result (output)
JSON
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"created": {
"description": "Identifiers of the objects created.",
"items": {
"type": "string"
},
"type": "array"
},
"deleted": {
"description": "The identifiers of what was deleted.",
"items": {
"type": "string"
},
"type": "array"
},
"document_changed": {
"description": "The drawing on screen is another one (opened, closed or changed tab): the lists of changes do not apply.",
"type": "boolean"
},
"modified": {
"description": "Whether there are unsaved changes; in results of changes, the identifiers of the objects changed.",
"items": {
"type": "string"
},
"type": "array"
},
"truncated": {
"description": "The lists were cut at the limit.",
"type": "boolean"
}
},
"required": [
"created",
"modified",
"deleted",
"document_changed",
"truncated"
],
"type": "object"
}