> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pulze.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> The official Scene Manager 3 client for Python. It has no dependencies, so it also runs inside 3ds Max's own Python.

```bash theme={null}
pip install pulze-scenemanager
```

```python theme={null}
import scenemanager as sm

scene = sm.connect()

for setup in scene.setups.list_setups().setups:
    print(setup.id, setup.name)
```

It needs Python 3.10 or newer.

## Connecting

```python theme={null}
scene = sm.connect()   # http://127.0.0.1:45710
```

`connect()` finds Scene Manager on this computer. Each request times out after 120 seconds; pass `timeout` to change that.

## Finding a method

Each endpoint in the [API reference](https://docs.pulze.io/scene-manager-3/api-reference/introduction.md) is a method. Methods are grouped by the first part of the path and named after the operation, in snake case:

```python theme={null}
scene.groups()        # ['activation', 'comments', 'document', 'folders', 'hdri', ...]
dir(scene.setups)     # every method in a group
help(scene.setups.activate_setup)
```

| Endpoint | Method |
| - | - |
| `GET /setups` | `scene.setups.list_setups()` |
| `POST /setups/{id}/activate` | `scene.setups.activate_setup(setup_id)` |
| `POST /values` | `scene.values.set_values(body=...)` |
| `POST /render` | `scene.render.start_render(body=...)` |
| `POST /scene/script` | `scene.scene.run_script(body=...)` |

Path parameters are positional, query parameters are keyword arguments, and a request body goes in `body=`. Results support dot access, and `to_dict()` returns the raw data. Images such as thumbnails and shots come back as `bytes`.

The package ships `models.pyi`, so your editor and type checker know every result's fields.

## Activating and rendering

```python theme={null}
setups = scene.setups.list_setups().setups
kitchen = [s for s in setups if s.name.startswith("Kitchen")]

result = scene.setups.activate_setup(kitchen[0].id, body={"wait": True})
for item in result.results:
    for skipped in item.skipped:
        print(item.target, skipped.name, skipped.reason)

scene.render.start_render(body={"setups": [s.id for s in kitchen]})
batch = scene.render.wait()   # returns when the batch is done or stopped

for item in batch.items:
    print(item.name, item.status, item.output)
```

`scene.render.wait()` checks the render every two seconds. Pass `timeout` in seconds to stop waiting with a `TimeoutError`.

## Running a script

```python theme={null}
answer = scene.scene.run_script(body={"language": "python", "code": "from pymxs import runtime as rt\nresult = rt.maxFileName"})
print(answer.value)
```

`language` is `maxscript` (the default) or `python`. In Python, set a variable named `result` to return a value.

## Errors

```python theme={null}
from scenemanager import ApiError

try:
    scene.render.start_render(body={"setups": [setup_id]})
except ApiError as refused:
    if refused.status == 409:
        print("A batch render is already running.")
    else:
        raise
```

`ApiError` has the HTTP `status`, the response `body`, and Scene Manager's message. Without a licence, every call except `scene.health.get_health()` raises it with status `402`. If Scene Manager isn't running, `status` is `0`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.