---
title: "Vantage Scripting"
canonical: "https://documentation.chaos.com/space/LAV/1506541903/Vantage+Scripting"
format: markdown
---
This page provides information about Python scripting in Chaos Vantage.


## **What Vantage Scripting Is?**

---

Scripting lets a scene in Vantage react on its own: a light switches on two seconds into an animation, an object changes material when you click it, or a lighting mood changes when you press a key. You get this by attaching a small program, written in Python, to the scene.

It is meant for interactive presentations, guided walkthroughs, and simple product configurators. The same Python engine is also used by the Vantage Scene MCP, which lets AI assistants work with the scene. For more information, see <u>[Vantage Scene MCP](https://docs-chaos.atlassian.net/wiki/spaces/LAV/pages/1505853480)</u>.


## **How a Script Works**

---

A script is a list of "when this happens, do that" instructions. Each scene can have one script, and it follows the same cycle every time:

1. **The script starts.** When you load it, the script says which moments it wants to hear about, for example "at 2 seconds into the animation" or "whenever a key is pressed". This can only be set up at the start.
2. **Something happens in Vantage.** The animation reaches that moment, the camera moves, or you click.
3. **Vantage briefly pauses and asks the script what to do.** The script can look at the scene and change lights, objects and cameras.
4. **The changes appear.** As soon as the script finishes its reaction, Vantage applies all the changes and carries on rendering.

A script can also describe a starting state for the scene, called a **reset**. Vantage returns the scene to it when an animation starts or ends and when you enter walk mode, so every run begins from the same clean state.

Scripts run in a separate helper program(*vscript.exe*) that comes with Vantage. If a script has a mistake, the error is shown in the Script Editor instead of affecting the scene.


## **Getting Started**

---

1. Open a scene as usual.
2. Load a script with **Scripting > Open Script...** and pick a Python file (.py). To start from an empty script, use **Scripting > New Script**. Recently used scripts appear under **Scripting > Recent Scripts**.
3. Edit, save and restart the script from the Script Editor panel (**Scripting > Open Script Editor**). Messages and errors from the script are shown there too.
4. Try things out in the **Scratchpad** tab of the same panel. It runs short pieces of Python against the open scene, which is handy for quick experiments. Each run is a single undo step, so you can revert it with **Ctrl+Z**.
5. To unload the script, use **Scripting > Close Script**.

> ⚠️ The **Scripting** menu is unavailable while a Live Link session is connected.


### **Sample Scenes and Scripts**

---

The scripting component has to be part of your Vantage installation. Installations that include it also ship ready-made example scenes with scripts in the **samples\vscript** folder of the installation directory (default directory is *C:\Program Files\Chaos\Vantage\samples\vscript*) :

- **Hello world** – The simplest script. A box moves past two lamps and they blink at set times. Start here.
- **Stage cues** – A timed light show. Spotlights cut, change color and follow the moving camera.
- **Walk the lit path** – A small game. Walk across a field of tiles, lanterns light the safe steps, and a wrong step sends you back.
- **Pick and highlight** – Click an object to recolor it and point a spotlight at it; click empty space to clear.
- **Any scene** – Short scripts that work with whatever the scene contains, such as "click to make an object vanish", "a light that follows you", "switch the mood of the lighting" and "capture the viewport".


## **What a Script Can React To**

---

A script can respond to five kinds of moments. It can listen to as many of them as it needs, and to the same kind more than once.

- **A point in the animation (*****onTime*****)** – When the animation reaches a set time, for example 2.5 seconds. Example: turn on the lamps when the car enters the garage.
- **Every frame (*****onFrame*****)** – Many times per second, while an animation plays or you walk around. It can also be switched on while you are simply editing the scene. Example: make a light gently pulse, or keep something pointed at the viewer.
- **The camera moves (*****onCameraMove*****)** – When a chosen scene camera moves, or when you move around in walk mode. Example: reveal an object when you get close to it, or make a lantern follow you.
- **A key is pressed or released (*****onKey*****)** – Any keyboard key, including keys Vantage normally uses for its own shortcuts. The script decides which keys it takes over; all other keys keep working normally. Example: press 1, 2 or 3 to switch between lighting setups.
- **A mouse button is clicked (*****onMouseButton*****)** – A click anywhere in the image, together with the position of the click. Example: click an object to highlight it.

Timed moments only happen while an animation is playing. Camera and frame moments also happen in walk mode and navigation, so a scene can be interactive without any animation at all.


## **What a Script Can Look At and Change**

---

A script works with three kinds of things in the scene: objects (the geometry), lights and cameras. It finds them by the names they have in the scene, or by going through a list of all of them.


### **Objects**

---

- See the object's name.
- Show or hide it.
- Move, rotate and scale it.
- Get the box that tightly surrounds it, and how far a given point is from that box. Useful for "is the visitor close to this table?"
- Give it a different material. Any material listed in the Material Browser can be used, including materials from the scene file, from Chaos Cosmos assets and materials created in Vantage.


### **Lights**

---

- Switch it on or off; change its brightness and color.
- Turn shadows on or off and make them softer or sharper.
- Choose whether it lights up surfaces, creates shiny highlights, or both.
- Change its size and shape: the width and height of rectangle lights (or make them round), the size of sphere and cylinder lights, and the cone angles of spotlights.
- Make an area light invisible to the camera, light from both sides, or not fade with distance.
- Change the position of the sun with its altitude and azimuth.
- Move and rotate it; check how far a point is from it.
- Create a new light: point, spot, directional, rectangle, disc, sphere or cylinder.


### **Cameras**

---

This includes every camera in the scene, the camera you use in walk mode and the camera Vantage currently renders through.

- Move and rotate it, or point it at a target.
- **Lens** – Zoom, focal length, field of view, or a flat (orthographic) view without perspective.
- **Exposure** – Aperture (f-number), shutter speed, ISO, exposure value, white balance and darkened corners (vignetting).
- **Depth of field** – Turn background and foreground blur on or off, set the focus distance and the shape of the blur.
- **Tilt and shift** – Corrections such as keeping vertical lines straight in architecture.
- Lens distortion, near and far cut-off distances, the image size saved with the camera, and 3D stereo settings.
- Create a new camera, starting from the settings of the current view.


### **Information About the Scene and the Viewer**

---

- Lists of all objects, lights, cameras and materials in the scene.
- Whether the scene has an animation, whether it is playing, its start, end and current time, and its frame rate.
- Whether you are in walk mode.
- Where the scene file is saved on disk.
- Which axis is up, the size of a scene unit in meters, and the color space the scene uses.
- What is under a point in the image: which object, where exactly it was hit in 3D, which way the surface faces there, and how far away it is. This is what makes "click on an object" interactions possible.
- A copy of the image currently shown in the viewport.


### **Regular Python**

---

Scripts are ordinary Python 3.15 programs, so they can also do anything Python can do on its own: calculations, reading data files stored next to the script, or using other Python add-on libraries. The NumPy math library is included and is the way to do math with positions and rotations.


## **Script Sandbox**

---

By default, scripts run in a sandbox that protects your computer from a script you did not write yourself. A sandboxed script can read and write files in its own folder and read files in the folder of the open scene. It has no network access, cannot use the clipboard or start other programs, and sees only basic system environment variables.

To change what scripts may do, open **Preferences > Scripting > Script sandbox**:

- **Run scripts in a sandbox** – Toggles the sandbox on or off.
- **Internet** – No access, outgoing connections, or outgoing and incoming connections.
- **Local network connections** – Allows connections to other computers on your local network.
- **Files** – No access, read, or read and write, separately for the script folder and the scene folder. Use **Add Folder** to give access to other folders.
- **Starting other programs** and **All environment variables** – Allow these system features.
- **Warn when scripts run without the sandbox** – Asks for confirmation before a script runs unprotected.

> ⚠️ Please note that changes to folder access apply right away; all other changes apply after Vantage restarts. Scripts can never change these settings themselves.


## **Current Limitations**

---

Many things you can do by hand in Vantage cannot be done from a script yet. The following actions are not yet possible with the scene scripting with suggestions for a workaround:

- **Fine-tune a material** (its color, shininess, roughness or texture). *Instead: prepare the material variants in advance and swap whole materials.*
- **Add, delete or copy objects.** New lights and cameras can be created, but geometry cannot be added, and nothing can be deleted.* Instead: put everything in the scene beforehand and show or hide it.*
- **Change the sky and environment, the background, post-processing effects or render quality settings.** Only objects, lights and cameras can be reached; the sun is controlled through its light settings. *There is no way around this yet.*
- **Play, pause or jump to a time in the animation.** A script can only read the animation's state. *Instead: start and stop playback by hand.*
- **Switch the active camera or change scene states.** *Instead: switch cameras and scene states by hand.*
- **Render pictures or videos.** A script can take a copy of the image shown in the viewport, but not start a render.* Instead: use Vantage's normal render and export*.
- **Show buttons, sliders or menus of its own.** *Instead: use keyboard keys and mouse clicks as controls.*
- **React to mouse movement, hovering or the scroll wheel.** Only mouse button clicks are available. *Instead: use clicks or keys.*
- **Check what lies in an arbitrary direction in 3D** (for example, "is there a wall in front of this lamp?"). Only "what is under this point of the image" is available.* Instead: use distances to the boxes around objects.*
- **Open another scene.** A scene script cannot do this. An AI assistant connected through Scene MCP can.
- **Run several scripts on one scene.** Only one script per scene. *Instead: combine them into one script.*
- **Start listening to new moments while running.** All moments are chosen when the script starts. *Instead: listen to everything at the start and ignore what is not needed.*
- **Have the script load automatically with the scene.** The script is loaded by hand each time. *Instead: use ****Scripting > Recent Scripts**** for quick access.*
- **Run on a Live Link scene.*** Instead: export the scene to a .vrscene file and open it in Vantage.*


## **Good to Know**

---

- **Keep reactions short.** Vantage pauses rendering while a script reacts, so slow work, especially in the every-frame reaction, makes the view stutter.
- **Look things up when you need them.** In an animated scene, values change over time. A script should ask for a light or camera at the moment it reacts, not reuse one it fetched earlier.
- **Write a reset.** Describing the starting state makes every playback and walk-through begin the same way.
- **Only take over the keys you need.** If a script claims every key, nothing else in Vantage gets keyboard input: no navigation, no undo, no shortcuts.
- **Names must match exactly.** A script finds objects, lights, cameras and materials by the names they have in the scene.
- **Some settings only apply to some lights.** Changing a spotlight's cone angle on a sphere light, for example, simply does nothing.
- **Lights and cameras a script creates stay in the scene** after the script is closed.
- **Extra Python libraries must be made for Python 3.15** to work.

For developers, the full Python API reference is included with Vantage in **samples\vscript\VSCRIPT_API.md**.