---
title: "Utility"
description: "Utility functions and types in the Python API"
url: https://developer.disguise.one/python-api/guides/utility/
---

# Utilities

Globally available utility functions and types which are unique to Designer.

## Execution context and understanding errors

When executing Python code, your script is indented and embedded within a function called `userScript`. Errors within the userScript are caught and reported with context about the line number and the specific error that occurred. The `userScript` function body starts on line 10 of the overall script, so when an error occurs, it will reference this offset line number. For example, an error referencing line 10 actually refers to the first line of your script.

**Debugging tip:** When an error occurs, add `print()` statements to trace execution and help identify what went wrong.

For more information about the execution environment, see the [Python Environment](/python-api/environment#execution-context) page.

## Types

In the API reference, `Type` always refers to a Python type. There is no `Type` class. The class names themselves are valid types. For example, `Vec` is a valid `Type` value.

## Enums

From r34.2, enums are their own types rather than integers, for example [`MachineRole`](/python-api/docs/machinerole). Each enum’s reference page lists its values. If you are updating older scripts, see [Enums in the Python API (r34.2)](/python-api/api-changes/enums-upgrade).

-   `print(value)` shows the enum and its value’s name, e.g. `<MachineRole Actor>`, and `value.toString()` gives just the name, e.g. `'Actor'`.
-   `int(value)` gives its integer, and `MachineRole.fromInt(3)` builds one from an integer.
-   An enum compares equal to its integer, so `machine.role == 3` still works, but `machine.role == MachineRole.Actor` is clearer.
-   Enums cannot be serialised with `json`. Return `int(value)` or `value.toString()` from scripts and plugin functions instead.

## ReflectionValue

`ReflectionValue` is equivalent to Python’s `Any` type and accepts any value.

## FieldInfo

Access as follows: `getattr(ClassName.property.fget, 'field', None)`. If `field` is not found, it is incompatible with getting the `FieldInfo`.

## Vector types

Note that `Vec` and `Vec3` are the same class object, aliased under different names.

| Task | Python |
| :-- | :-- |
| **Create a 2D float vector** | `Vec2(x, y)` - see [`Vec2`](/python-api/docs/vec2) |
| **Create a 3D float vector (for position, size, etc.)** | `Vec(x, y, z)` or `Vec3(x, y, z)` - see [`Vec`](/python-api/docs/vec) |
| **Create a 4D float vector** | `float4(x, y, z, w)` - see [`float4`](/python-api/docs/float4) |
| **Create a 2D integer vector (for resolution, etc.)** | `Int2(width, height)` - see [`Int2`](/python-api/docs/int2) |

## Timecode

| Property | Access |
| :-- | :-- |
| **Timecode time in seconds** | `tc.t` - see [`Timecode`](/python-api/docs/timecode) |
