Designer Plugins
Plugins for Disguise Designer software.
Plugins for Disguise Designer software.
This page describes the Python execution environment within Designer, including available utility functions, restrictions, execution context, and best practices.
Designer uses an embedded Python interpreter that provides access to the Designer API. Python scripts executed through the /api/session/python/execute endpoint run in a controlled environment that has been configured for stability and integration with Designer’s core systems.
Designer uses Python 2.7 for its embedded interpreter. While Python 2.7 reached end-of-life in 2020, it remains the version used within Designer for compatibility and stability reasons.
Important Considerations:
print is a statement, not a function)When you execute Python code through the API, your script is automatically wrapped in a function called userScript. This has some implications for error reporting and execution:
Your code is indented and embedded within a function structure:
def userScript():
# Your code here (indented)
pass
Because of this wrapping, error line numbers are offset by 10. When you see an error referencing line 10, it actually refers to the first line of your script. If an error references line 15, it’s line 5 of your actual code.
Example:
Error at line 12: NameError: name 'foo' is not defined
This error is actually on line 2 of your script.
print() statements to trace executionWhen using the /api/session/python/execute endpoint without a module name, some additional global variables and functions are available to help access the Designer environment. These are aimed at simplifying Python implementation.
Note: For real-time feedback about timing elements, use the Live Update API instead.
trackTime() -> float
Returns the current track time for the current transport in seconds.
Equivalent to: LocalState.localState().currentTransport.player.tCurrent
Example:
# Add a layer at the current playhead position
current_time = trackTime()
layer = guisystem.track.addNewLayer(VideoModule, current_time, 60, 'My Layer')
runningTime() -> float
Returns the length of time the application has been running in seconds.
Equivalent to: LocalState.localState().currentTransport.player.tRunning
Example:
# Check how long Designer has been running
uptime = runningTime()
print("Designer has been running for {} seconds".format(uptime))
The execution environment provides direct access to key Designer objects:
| Object | Description |
|---|---|
guisystem | Main GUI system - access to track, layers, and UI state |
state | Current Designer state - access to stage, devices, and project |
d3 | Global Designer application object |
resourceManager | Resource manager for loading, creating, and managing resources |
Resource | Base resource class for creating typed resources |
Example:
# Access the current track
track = guisystem.track
# Get all video layers
video_layers = [l for l in track.layers if l.moduleType() == VariableVideoModule]
# Access the stage
stage = state.stage
# Access devices
devices = state.devices
# Load a resource
clip = resourceManager.loadOrCreate('objects/videoclip/myclip.mov.apx', VideoClip)
To ensure stability and prevent conflicts with Designer’s internal systems, some functionality has been removed or restricted in the Designer Python environment.
The following standard Python modules have been removed and are not available:
threading - Multi-threading is not supported to prevent race conditions and ensure deterministic behaviorsys - System-specific parameters and functions are restrictedWhy these restrictions?
sys module access could allow modification of the Python environment in unsafe waysThe following Designer-specific functionality cannot be accessed through the Python environment:
If you need functionality that’s restricted:
Python scripts execute on Designer’s main application thread, which means Designer will pause while your script runs. To prevent scripts from hanging the application, a timeout interrupt is enforced.
Timeout Behavior:
pythonApiExecutionTimeout experimental option in d3ManagerKeyboardInterrupt is executedTimeoutError in the responseBest practice: Break complex operations into smaller steps or chain multiple execute calls through the API.
Good:
# Quick operation
layer = guisystem.track.addNewLayer(VideoModule, trackTime(), 60, 'Video')
layer.findSequence('video').sequence.setResource(0, my_clip)
Avoid:
# Long loop that could block Designer and hit the timeout
for i in range(10000):
# Heavy processing
pass
Always use the resource manager and follow proper save/dirty patterns. See the Resources Guide for details.
# Mark resource as dirty before changes
markDirty(my_resource)
# Make changes
my_resource.property = new_value
# Save changes
my_resource.saveOnDelete()
Always include error handling to prevent script failures from affecting Designer:
try:
layer = next(l for l in track.layers if l.name == "My Layer")
# Do something with layer
except StopIteration:
print("Layer not found")
except Exception as e:
print("Error: {}".format(str(e)))
When creating resources, use descriptive names to make your project easier to navigate:
# Good
video_clip = resourceManager.loadOrCreate('objects/videoclip/hero_shot.mp4.apx', VideoClip)
# Less clear
clip = resourceManager.loadOrCreate('objects/videoclip/v1.mp4.apx', VideoClip)
For detailed information on specific workflows, consult the Python API Guides:
For questions or to report issues with the Python environment, contact integrations@disguise.one.