Working with Script Plugins

VRED Professional supports custom Python modules, called script plugins. They have to be copied to a specific location (see Loading a Script Plugin) for them to be automatically loaded during the next VRED start-up. After this, all loaded script plugins can be found listed in the Scripts menu.

Scripts menu

How are Script Plugins Handled?

Script plugins are created to be independent from VRED's 'main' context, in which every Python code executed in the Script Editor, Terminal, or Script preferences, or scripts loaded together with VPBs is run. Script plugins are not affected by creating a new scene, unlike the 'main' context, which is, and is also flushed and reset to its default state.

Every Python command executed in the Terminal or Script Editor will not influence plugins or interfere with each other.

Loading a Script Plugin

Use these instructions to add the SimpleExample or your own script plugin to the Scripts menu.

If you are running a legacy version of VRED, you may not have a Script menu; therefore, you will need to add one to your menu bar. Before continuing, a Scripts menu will need to be created. See How to Create a Scripts Menu for instructions on how to do this.

Once a Scripts menu is created, note that it won't appear in the menu bar until you've loaded a script into your ScriptPlugins folder and have restarted VRED. So, let's look at how to load a script plugin.

For Windows Users

  1. Once you've created a ScriptPlugins folder, in a browser, navigate to:

    C:\ProgramData\Autodesk\VREDPro-<internalVersion>\examples\plugins

  2. Copy the SimpleExample folder and paste it into the ScriptPlugins folder:

    C:\Users\<username>\Documents\Autodesk\VRED-<internalVersion>\ScriptPlugins\

  3. Save your work, then close and restart VRED. The Scripts menu is now displayed in the menu bar. When you select it, you'll see the example, called SimpleExample, listed.

For Mac Users

  1. Once you've created a ScriptPlugins folder, in a Finder window, navigate to:

    /Users/Shared/Autodesk/VRED-<internalVersion>/examples/plugins/SimpleExample

  2. Copy the SimpleExample folder and paste it into the ScriptPlugins folder:

    C:/Users/<user>/Documents/Autodesk/VRED-<internalVersion>/ScriptPlugins/

  3. Save your work, then close and restart VRED. The Scripts menu is now displayed in the menu bar. When you select it, you'll see the example, called SimpleExample, listed.

How to Update a Script Plugin

To update a script plugin, use Edit > Reload Script Plugins and close any open plugin windows, since the running code in memory cannot be updated, otherwise. Edit the plugin, close its window, then initiate Edit > Reload Script Plugins to update the plugin.

If the plugin needs to do some house keeping when its unloaded, try this callback function:

This example is from QtQuickStreaming.py:

def onDestroyVREDScriptPlugin():
    """
    onDestroyVREDScriptPlugin() is called before this plugin is destroyed.
    In this plugin we want to stop all processes.
    """
    streamingPlugin.deleteAllProcesses()

Script plugins have access to VREDPluginWidget, VREDMainWindow and vrMainWindow, which are copied into the globals of each plugin when it is loaded or re-loaded.

Scripted Plugins

VRED comes with an assortment of scripted plugins, which are listed in the Scripts menu.