> For the complete documentation index, see [llms.txt](https://stage-precision.gitbook.io/grid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stage-precision.gitbook.io/grid/scripting/object-filters.md).

# Object Filters

### Creating an Object Script Filter

Object Script Filters are created from the **Maps** tab of an Object.

Select the Object in the Project Tree and open the **Maps** tab in the Inspector.

Under **Filter**, click the **+** button and navigate to:

**Manipulation → Script**

<div align="left"><figure><img src="/files/S1MYf5w1UO6dvhTnysDC" alt="" width="458"><figcaption></figcaption></figure></div>

A new Script Filter is then added to the Object's Filter pipeline.

### Editing the Filter Script

The Python code is available directly inside the **Script** section of the added Filter.

<div align="left"><figure><img src="/files/4nugROnkg2IoHxd7voIF" alt="" width="434"><figcaption></figcaption></figure></div>

A new Object Script Filter uses the following function:

```python
def filter(obj, data):
    return data
```

The function receives:

* `obj` — the Object currently being processed
* `data` — the data currently passing through the Filter

The processed `data` must be returned at the end of the function.

For example:

```python
def filter(obj, data):
    pos = data["pos"]
    rot = data["rot"]

    pos[0] = pos[0] + 3

    data["pos"] = pos
    data["rot"] = rot

    return data
```

{% hint style="info" %}
An Object Script Filter behaves like other Filters in the processing pipeline. It is evaluated continuously as part of the Engine Tick and processes the Object data passing through it.
{% endhint %}

### Accessing the Object

The `obj` argument provides access to the Object currently being processed.

This can be used when the filter logic needs information from the Object itself in addition to the data passed through the filter.

```python
def filter(obj, data):
    print(obj)

    return data
```

### When to Use Object Filters

Object Filters are useful when Object data needs custom processing that is not covered by the existing Filter options.

Typical use cases include:

* Modifying position or rotation data
* Applying custom offsets
* Transforming Object data
* Implementing project-specific processing logic
* Adding custom processing steps to an existing Map or Filter pipeline

Object Filters are part of the Map and Filter processing system and are intended for processing Object data rather than general project scripting.
