disguise developers

Designer Plugins

Plugins for Disguise Designer software.

This page contains useful Python code snippets for common Designer tasks. For more comprehensive guides, see the Python API Guides section below.

Add Video Layer at current track time

guisystem.track.addNewLayer(VariableVideoModule, trackTime(), 60, 'Video');

See the Track & Sequencing Guide for more details on working with layers.

Split track at current track time

guisystem.track.splitSectionAtBeat(trackTime());

(note that the above two examples use the Execution Utility Functions shorthand)

See the Track & Sequencing Guide for more details on working with tracks.

Add a projector & set it’s resolution to 4K

projector = resourceManager.loadOrCreate('objects/projector/myprojector.apx', Projector)
projector.resolution = Vec2(3840, 2160)

See the Stage Guide for more details on working with stage objects and the Resources Guide for resource management patterns.

Add and configure an OSC device

# Create OSC device using resource manager
osc = resourceManager.loadOrCreate('objects/OscDevice/PluginMonitor.apx', OscDevice)

# Configure OSC device
osc.sendIPAddress = '127.0.0.1'  # IP where the plugin is running
osc.sendPort = {port}  # Port where our plugin is listening
osc.receivePort = {port} + 1  # Use next port for Designer to listen

# Add the device to devices array if not already there
device_exists = False
for device in state.devices.devices:
    if device.path == osc.path:
        device_exists = True
        break
if not device_exists:
    state.devices.devices.append(osc)
    print("Added OSC device to state.devices")

# Start the device if not already started
if not osc.started:
    osc.start()

See the Devices Guide for more details on working with the Device Manager and different device types.

List all resources of a type

resourceManager.allResources(OscDevice)

See the Resources Guide for comprehensive resource management patterns.

Set ExpressionVariable to a value

# Find our device
existing_devices = resourceManager.allResources(ExpressionVariablesDevice)
for device in existing_devices:
    if device.path == 'objects/ExpressionVariablesDevice/PluginVariable.apx':
        for var in device.container.variables:
            if var.name == 'plugin_value':
                var.defaultFloat = {value}
                print("Updated plugin_value to %f" % {value})
                break

See the Expressions Guide for more details on working with expression variables.

Create a 5x5 grid of LED screens with rainbow keyframes

def createOddEvenLEDScreenGrid(nXScreens, nYScreens, screen_size, screen_gap):
    
    screen_offset = screen_size + 2*screen_gap
    
    x_offset = (nXScreens/2)*screen_offset - screen_offset/2
    y_offset = screen_size/2
    
    mapping_even_path = 'objects/directprojection/even_screens_direct.apx'
    mapping_even = resourceManager.loadOrCreate(mapping_even_path, DirectProjection)
    
    mapping_odd_path = 'objects/directprojection/odd_screens_direct.apx'
    mapping_odd = resourceManager.loadOrCreate(mapping_odd_path, DirectProjection)
    
    for i in range(nYScreens):
        for j in range (nXScreens):
            new_resource = resourceManager.loadOrCreate(
                'objects/ledscreen/ledscreen_{idx}.apx'.format(
                    idx=i*nYScreens + j ), LedScreen)

            new_resource.scale = Vec(screen_size, screen_size, 0)
            new_resource.offset = Vec(-x_offset + screen_offset*j, y_offset + screen_offset*i, 0)
            new_resource.resolution = Vec(1920, 1080)
            
            if i % 2 == 0:
                mapping_even.screens.append(new_resource)
            else:
                mapping_odd.screens.append(new_resource)
            
    return [mapping_even_path, mapping_odd_path]

def createVideoLayer(layer_name, start_time_seconds, length_seconds):
    return guisystem.track.addNewLayer(VariableVideoModule, start_time_seconds, length_seconds, layer_name) 

def makeSineWaveKeyFrame(layer, field, initial_value, offset_value):
    import math
    layer.fields[field].disableSequencing = False
    for i in range(1, 60):
        layer.fields[field].sequence.setFloat(i, offset_value + initial_value*math.sin(math.pi*((5 - (i % 10) )/5.0)))
    
if __name__ == '__main__':
    
    mapping_paths = createOddEvenLEDScreenGrid(5, 5, 5, 0.5)
    
    layer_1 = createVideoLayer('layer_1', 0, 60)
    layer_1.fields[10].sequence.setString(0, 'objects/videoclip/sample/george.jpg.apx')
    layer_1.fields[2].sequence.setString(0, mapping_paths[0])
    
    layer_2 = createVideoLayer('layer_2', 0, 60)
    layer_2.fields[10].sequence.setString(0, 'objects/videoclip/sample/ada.jpg.apx')
    layer_2.fields[2].sequence.setString(0, mapping_paths[1])
    
    makeSineWaveKeyFrame(layer_1, 20, 360, 0) # Hue
    makeSineWaveKeyFrame(layer_1, 36, 1, 1) # Size
    makeSineWaveKeyFrame(layer_1, 41, 90, 0) # Rotation
    
    makeSineWaveKeyFrame(layer_2, 20, -360, 0) # Hue
    makeSineWaveKeyFrame(layer_2, 36, 1, 1) # Size
    makeSineWaveKeyFrame(layer_2, 41, -90, 0) # Rotation

This example demonstrates creating stage objects, managing resources, and working with layers and sequences. See the Stage Guide, Resources Guide, and Track & Sequencing Guide for more details.

Locate all feed rectangles

import json

feed_scenes = resourceManager.allResources(FeedScene)
output = []

for scene in feed_scenes:
    scene_info = {
        "Scene UID": str(scene.uid),
        "FeedRects": []
    }
    
    if hasattr(scene, "feedRects"):
        for rect in scene.feedRects:
            rect_info = {
                "FeedRect UID": str(rect.uid),
                "Local Position and Size": str(rect.rect) if hasattr(rect, "rect") else "Not found",
                "Screen Position and Size": str(rect.screenRect) if hasattr(rect, "screenRect") else "Not found",
                "Output Rectangle": str(rect.outputRect) if hasattr(rect, "outputRect") else "Not found"
            }

            # Reference Display Extraction
            if hasattr(rect, "referenceDisplay"):
                ref_disp = rect.referenceDisplay
                ref_info = {
                    "Reference Display": str(ref_disp),
                    "uid": str(ref_disp.uid) if hasattr(ref_disp, "uid") else "Unknown",
                    "path": str(ref_disp.path) if hasattr(ref_disp, "path") else "Unknown"
                }
                if hasattr(ref_disp, "parent"):
                    parent = ref_disp.parent
                    ref_info["Parent UID"] = str(parent.uid) if hasattr(parent, "uid") else "Unknown"
                    ref_info["Parent Path"] = str(parent.path) if hasattr(parent, "path") else "Unknown"
                rect_info["Reference Display Info"] = ref_info

            # Display Target Extraction
            if hasattr(rect, "displayTarget"):
                disp_target = rect.displayTarget
                disp_info = {
                    "Display Target": str(disp_target),
                    "uid": str(disp_target.uid) if hasattr(disp_target, "uid") else "Unknown"
                }
                rect_info["Display Target Info"] = disp_info

            scene_info["FeedRects"].append(rect_info)

    output.append(scene_info)

print(json.dumps(output, indent=4))

See the Feed Operations Guide for comprehensive information on working with feeds and feed rectangles.


Python API Guides

For more comprehensive guides on working with the Designer Python API, check out these resources:

For detailed API reference documentation, see the API Documentation.