Suite operations
suite.view.capture
Image (PNG) of the view, of the extents or of a window, to check the result.
- Program: All programs
- Type of action: Reads the drawing
- Read only
- Since version 2027.0.0-beta.6
Draws the chosen area into a PNG image (up to 2048 pixels wide) with the same rendering as plotting, without a graphics card, and returns it in Base64. Use it to look at what was drawn. The height follows the shape of the area. With a layout on screen, the image is its sheet with the viewports (window and area in paper mm); layout picks another layout or "Model" (off screen, the view area becomes the extents). The viewports of each layout are listed by cad.layout.list. Inside a layout viewport (MSPACE), the view area is the part of the sheet it covers, with what it shows of the model now; viewport (the identifier) captures any layout viewport the same way. In both cases the answer has viewport with the part of the model it shows (model_area, in drawing units) and the scale. Linetypes follow LTSCALE at once; a dash pattern that would repeat more than 4000 times along one segment is drawn continuous (too dense to see): raise LTSCALE.
- MCP tool
badbit_view_capture
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
area | CaptureArea | No | The area: in a measurement, the value (in square drawing units); in a capture, what becomes the image: view (what is on screen, the default), extents (everything drawn) or window. |
layout | string | null | No | The layout (by name; "Model" is model space). |
viewport | string | null | No | The identifier of the layout viewport. |
width | integer | null | No | The width: of an image, in pixels (64 to 2048, default 1024); of a named view, in drawing units. |
window | array<number> | null | No | Window [xmin, ymin, xmax, ymax] in drawing units (in the paper space of a layout, in mm). |
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. |
failed | -32005 | The operation failed. |
Example
MCP
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"area": "extents",
"width": 800
},
"name": "badbit_view_capture"
}
}Python
import badbit
result = badbit.suite.view.capture(area="extents", width=800)LISP
(badbit-call "suite.view.capture" '(("area" . "extents") ("width" . 800)))JSON-RPC
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"area": "extents",
"width": 800
},
"operation": "suite.view.capture"
}
}Commands that do the same
Full schema
JSON Schema 2020-12.
Parameters (input)
{
"$defs": {
"CaptureArea": {
"oneOf": [
{
"const": "view",
"type": "string"
},
{
"const": "extents",
"type": "string"
},
{
"const": "window",
"type": "string"
}
]
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"area": {
"$ref": "#/$defs/CaptureArea",
"description": "The area: in a measurement, the value (in square drawing units); in a capture, what becomes the image: view (what is on screen, the default), extents (everything drawn) or window."
},
"layout": {
"default": null,
"description": "The layout (by name; \"Model\" is model space).",
"maxLength": 256,
"minLength": 1,
"type": [
"string",
"null"
]
},
"viewport": {
"default": null,
"description": "The identifier of the layout viewport.",
"type": [
"string",
"null"
]
},
"width": {
"default": null,
"description": "The width: of an image, in pixels (64 to 2048, default 1024); of a named view, in drawing units.",
"format": "uint32",
"maximum": 2048,
"minimum": 64,
"type": [
"integer",
"null"
]
},
"window": {
"default": null,
"description": "Window [xmin, ymin, xmax, ymax] in drawing units (in the paper space of a layout, in mm).",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 4,
"minItems": 4,
"type": [
"array",
"null"
]
}
},
"type": "object"
}Result (output)
{
"$defs": {
"CapturedViewport": {
"properties": {
"id": {
"description": "Object identifier (32 hexadecimal digits), or command identifier in the command list.",
"type": "string"
},
"model_area": {
"description": "The part of the model the viewport shows [xmin, ymin, xmax, ymax], in drawing units.",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 4,
"minItems": 4,
"type": "array"
},
"scale": {
"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"
}
},
"required": [
"id",
"model_area",
"scale"
],
"type": "object"
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"area": {
"description": "The area: in a measurement, the value (in square drawing units); in a capture, what becomes the image: view (what is on screen, the default), extents (everything drawn) or window.",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 4,
"minItems": 4,
"type": "array"
},
"data": {
"description": "The PNG image in Base64.",
"type": "string"
},
"height": {
"description": "Text height; in zoom, the visible height; in images, the height in pixels; in a named view, in drawing units; in a layout viewport, the height of the model it shows, in drawing units.",
"format": "uint32",
"minimum": 0,
"type": "integer"
},
"mime": {
"description": "Type of the image (image/png).",
"type": "string"
},
"viewport": {
"anyOf": [
{
"$ref": "#/$defs/CapturedViewport"
},
{
"type": "null"
}
],
"description": "The identifier of the layout viewport."
},
"width": {
"description": "The width: of an image, in pixels (64 to 2048, default 1024); of a named view, in drawing units.",
"format": "uint32",
"minimum": 0,
"type": "integer"
}
},
"required": [
"mime",
"width",
"height",
"area",
"data"
],
"type": "object"
}