How do I write my first package in RV?

RV can be nearly infinitely customizable but it can be difficult finding documentation for where to begin developing your own plugins.
There are a couple of things that you should know.

RV offers a couple of ways to write plugins: Mu, Python, PySide and GLSL.

The best way to start with RV scripting is to use Python. Unfortunately, Python is not native to RV and most of “Python” commands that you will find in RV are bindings on top of Mu. However, this means that you can use nearly all commands that are available in Mu in Python.

Mu is the native scripting language and kind of looks like Perl. Most of the RV documentation that is historically available is written in Mu. Unfortunately, this is a difficult way for someone to get started scripting, so I won’t go too deep into it in this post, except for bindings from Python <-> Mu. If you have plenty of time and would like to understand how Mu works, you can find it by going to RV -> Help -> Mu User's Manual.

A simple package for RV contains 2 files, a .mu or .py plugin and a text PACKAGE file. PACKAGE file is a description file that RV’s package system will use to determine how to load your package. Syntax for PACKAGE file is in YAML.

  1. Download the following 2 files:

Copy paste this into an Example_Package_MyStuffMode.py file:

from rv import commands, rvtypes
from rv.commands import NeutralMenuState

class Example_Package_MyStuffMode(rvtypes.MinorMode):

    def __init__(self):
        rvtypes.MinorMode.__init__(self)

        globalBindings = None #[("Event-Name", self.eventCallback, "DescriptionOfBinding")]
        localBindings = None

        menu = [
            ("Example", [
                    ("Run Example", self.runExample, None, lambda: NeutralMenuState),
            ])
        ]

        self.init("Example_Package_MyStuff", globalBindings, localBindings, menu)

    def runExample(self, event):
        print "DEBUG: Example Ran."

def createMode():
    return Example_Package_MyStuffMode()

Paste this into a PACKAGE file:

package: MyStuff
author: Alexa Zalipyatskikh
organization: Autodesk
contact: support@shotgunsoftware.com
version: 1.0
requires: ''
rv: 7.3.1

modes:
- file: MyStuffMode
  load: immediate

description: |
  <p>Description of package here.</p>
  1. Now zip up the Example_Package_MyStuffMode.py and PACKAGE file into a Example_Package_MyStuff-1.0.rvpkg file. NOTE: You need to specify the version of the RV Package in the file name as well as the PACKAGE file itself. Otherwise RV won’t load the package.

  2. Launch RV and navigate to RV -> Preferences... -> Packages -> Add Packages... Then navigate to your Example_Package_MyStuff-1.0.rvpkg file. RV will ask you where you would like to install the package. This is your RV_SUPPORT_PATH area.

  3. Make sure that both of the checkmarks are ON next to the package, then restart RV.

  4. Open up Window -> Console and leave it where you can see it. You should now have an Example -> Run Example menu in RV. Click on Run Example. You should get a “Example ran” show up in the Console.

  5. You can modify your plugin in RV_SUPPORT_PATH (where you installed plugin) under RV_SUPPORT_PATH/Python/Example_Package_MyStuffMode.py. You will need to restart RV every time you modify the python file there, but you WON’T have to reload the package. If you’re modifying your Python outside of the RV_SUPPORT_PATH/Python/Example_Package_MyStuffMode.py, you will need to re-install the package every time.

  6. Congrats, you have installed your first package!

3 Likes

The Mu Programming Language manual is now available online also.

3 Likes