> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/hypersim/automation-api-and-scripting/automate-with-python-script/use-the-sequencer-tool.md).

# Use the Sequencer Tool

## Description

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-d6a680e26468ec21966cae6f50fa4ce4b7a5e682%2Fsequencer-tool-picto.png?alt=media" alt=""><figcaption></figcaption></figure>

The **Sequencer** tool, accessible from the **HYPERSIM** ribbon options, is designed to record and replay sequences of user interactions to automate HYPERSIM workflows. The recorded actions are saved as a Python script that follows the conventions and standards of the HYPERSIM API and can be executed on demand by the user.

The Sequencer allows users:

* to **create and execute** custom Python scripts.
* to **record** recurring and repetitive operations so they can be executed automatically.

This tool is not a replacement for an experienced Python programmer; rather, it enables users with limited knowledge of the HYPERSIM API or Python to create simple, reusable macros. It also helps experienced API users quickly recall code patterns or syntax they may no longer be familiar with.

## Create and open a Python script

Launch the **Sequencer** from the **HYPERSIM** ribbon. From the **File** menu, select **New Python Script** to create a new script or **Open** to edit an existing one. When creating a new script, enter a file name, choose a save location, and click **Save**.

Use the script editor to write your Python code. For information about the available functions and APIs, refer to the [**HYPERSIM API Reference**](https://www.opal-rt.com/docs/hypersim/automation-api-and-scripting/hypersim-api-references.md) documentation.

To run the script, click the **Play** button on the toolbar. Any output, messages, or errors generated during execution will be displayed in the Sequencer console.

## Record a Python script

{% stepper %}
{% step %}

### Open the design file and launch the Sequencer tool

Click **File > New Python…**, or click the **New Python Script** button directly. Enter a file name, choose the desired location, and click **Save**. Make sure the extension type is a .py.
{% endstep %}

{% step %}

### Record commands

For example, we want to script commands to start the simulation, perform a ScopeView acquisition, and then stop the simulation. Ensure that the design is opened beforehand; otherwise, the **Record Command** button will not be visible.

Once the design is open, start recording commands by clicking the **Record Command** button in the toolbar.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-5a451f4cdb66251a504bf5154bce90506ecb5172%2Fsequencer-tool-bar.png?alt=media" alt=""><figcaption></figcaption></figure>

Executing this manual sequence generates the following Python script.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-479b714e7997e954f8c8800f47012c8660005a03%2Fsequencer-editor-interface.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Run the script

Execute the script by clicking the **Play** button, ensuring that the design is already open.

You can view the results in **ScopeView** while the simulation is running, or in the exported PDF once execution is complete.
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/hypersim/automation-api-and-scripting/automate-with-python-script/use-the-sequencer-tool.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
