---
title: "file.render: Render preview — CAD kit command — Kition"
description: "Draws a view of the drawing as a PNG, a function of the drawing and the call alone: a space by `layout` (Model when left out) fitted to its extents, or in it a `window` in drawing units, an entity framed by its handle (`objectId`) or a named `view`; `layers` draws only those layers. Never the space shown, the view or the selection, and never a change. Its `window` and `unitsPerPixel` turn a pixel into drawing coordinates."
canonical: "https://developer.kition.ai/docs/kits/cad/commands/file.render"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/cad/commands/file.render](https://developer.kition.ai/docs/kits/cad/commands/file.render)

# file.render

**Render preview.** Draws a view of the drawing as a PNG, a function of the drawing and the call alone: a space by `layout` (Model when left out) fitted to its extents, or in it a `window` in drawing units, an entity framed by its handle (`objectId`) or a named `view`; `layers` draws only those layers. Never the space shown, the view or the selection, and never a change. Its `window` and `unitsPerPixel` turn a pixel into drawing coordinates.

- Kit: CAD 0.1.0 (.dxf); reference: [CAD kit commands](https://developer.kition.ai/docs/kits/cad.md)
- Changes the document: no

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `layers` | `string[]` | no | Draw only these layers (by name); others are left out. Without it, the layers the drawing shows. |
| `maxSize` | `integer` | no | The most pixels on the longer side, 1 to 4096; default 1024. |
| `scale` | `number` | no | Pixels per drawing unit, above 0; default: the view fitted to `maxSize`. A view larger than `maxSize` at that scale is drawn smaller. |
| `target` | `object` | no | The view: a space (`layout`), and in it a `window`, an entity (`objectId`, or a diagnostic's `path` `entity:<handle>`) or a named `view`. Without one, Model space fitted to its extents. |

## Call through cad_run

```text
cad_run {
  "path": "<file>.dxf",
  "steps": [{ "command": "file.render" }]
}
```

The required parameters, with placeholders for their types: not a tested example. Optional: `layers`, `maxSize`, `scale`, `target`. cad_run answers the step’s result in `completed[i].result`.

## Result

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `drew` | `string` | no |  |
| `height` | `integer` | no |  |
| `layout` | `string` | no |  |
| `mimeType` | `string` | no |  |
| `objectId` | `string` | no |  |
| `png` | `string` | no |  |
| `scale` | `number` | no |  |
| `unitsPerPixel` | `number` | no |  |
| `view` | `string` | no |  |
| `width` | `integer` | no |  |
| `window` | `number[]` | no |  |

```json
{
  "additionalProperties": false,
  "properties": {
    "drew": {
      "type": "string"
    },
    "height": {
      "type": "integer"
    },
    "layout": {
      "type": "string"
    },
    "mimeType": {
      "type": "string"
    },
    "objectId": {
      "type": "string"
    },
    "png": {
      "type": "string"
    },
    "scale": {
      "type": "number"
    },
    "unitsPerPixel": {
      "type": "number"
    },
    "view": {
      "type": "string"
    },
    "width": {
      "type": "integer"
    },
    "window": {
      "items": {
        "type": "number"
      },
      "type": "array"
    }
  },
  "type": "object"
}
```

## Parameter schema

```json
{
  "additionalProperties": false,
  "properties": {
    "layers": {
      "description": "Draw only these layers (by name); others are left out. Without it, the layers the drawing shows.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "maxSize": {
      "description": "The most pixels on the longer side, 1 to 4096; default 1024.",
      "type": "integer"
    },
    "scale": {
      "description": "Pixels per drawing unit, above 0; default: the view fitted to `maxSize`. A view larger than `maxSize` at that scale is drawn smaller.",
      "type": "number"
    },
    "target": {
      "additionalProperties": false,
      "description": "The view: a space (`layout`), and in it a `window`, an entity (`objectId`, or a diagnostic's `path` `entity:<handle>`) or a named `view`. Without one, Model space fitted to its extents.",
      "properties": {
        "layout": {
          "description": "A layout's name as inspect lists it in `layouts`, or \"Model\" (the default).",
          "type": "string"
        },
        "objectId": {
          "description": "An entity's handle: that entity framed with a margin, in its space.",
          "type": "string"
        },
        "path": {
          "description": "A diagnostic's target, `entity:<handle>`.",
          "type": "string"
        },
        "view": {
          "description": "A named view saved in the drawing (inspect's `views`), in Model space.",
          "type": "string"
        },
        "window": {
          "description": "[x1, y1, x2, y2]: the rectangle to draw, in drawing units of the space.",
          "items": {
            "type": "number"
          },
          "type": "array"
        }
      },
      "type": "object"
    }
  },
  "returns": "{png (base64), mimeType, width, height, scale, layout, window, unitsPerPixel, drew}",
  "type": "object"
}
```

Generated from the command list of @kition/cad-darwin-arm64@0.1.0 and the kit itself (cad_commands through @kition/cli@0.1.1, built from KitionAI/kition-cad@1ec542d).
