Skip to content

Scripting Introduction

OmniStep supports custom scripts that run in parallel with the operator, enabling users to implement new functionality. Those familiar with Unity will quickly grasp the concepts, and even if you are not, it's straightforward. Modules use the same core systems for data access and methods, but define their UI through Blender's native property system. Scripts use a simplified parameter system described below.

If you want to jump right in, visit the Demo Scenes and Experimental Modules for working code examples. The source code of OmniStep's built-in modules in the add-on directory is also a good reference.

Creating a New Script

First, you need to create the script text data block. Enable the 'Scripting' section and press Create Template to start:

alt text

Open a new area, set it to 'Text Editor' and select the newly created script to see and edit it:

alt text

Every script that works with OmniStep must be based on this template. You can remove or add methods, but the class CustomUserScript(UserScriptBase) is mandatory.

Custom UI Parameters

You can create custom UI parameters that are automatically exposed in the Sidebar. The template already includes an empty boolean variable. Change its type to STRING and press Read Parameters to update the UI:

alt text

Now set a value in the UI - write Hello World in the example_var field and press Write Parameters to update the script:

alt text

The value is now written to the script, but you can override it in the UI, which takes precedence. Values can come from the script (the default) or from the UI (the override). Overrides make it easy to test and iterate faster, only writing values back when needed.

Supported UI Types

OmniStep supports the following types: STRING, BOOLEAN, FLOAT, VECTOR, COLOR, OBJECT and COLLECTION. When you add new variables to the script, press Read Parameters to update the UI. After changing values in the UI, use Write Parameters to write them back to the script:

alt text

Here is the full list of supported types:

1
2
3
4
5
6
7
8
def custom_ui(self):
    self.add_property('my_string_var', 'STRING')
    self.add_property('my_bool_var', 'BOOLEAN')
    self.add_property('my_float_var', 'FLOAT')
    self.add_property('my_vector_var', 'VECTOR')
    self.add_property('my_color_var', 'COLOR')
    self.add_property('my_obj_var', 'OBJECT')
    self.add_property('my_collection_var', 'COLLECTION')