Import own Python extensions

import.py

print("Executing import script!")

# This small example shows how to write your own python modules.
# The imported module is located in vred/lib/python/myextension.py
# You have to import there all the vred extension modules on your own,
# only for the main script this is done by vred automaticly!

basedir = getFileIOBaseDir()

import myextension

loadGeometry("$VRED_EXAMPLES/geo/teddy.osb")
updateScene()
calcVertexNormals()

# add the script path to the python search path so
# you can put the myextension.py module also into
# the same directory as your main script file.
import sys
sys.path.insert(0, basedir)

ext = myextension.myextension()
ext.init()

myextension.py


from vrScenegraph import *
from vrController import *
from vrKey import *

class myextension:
    def __init__(self):
        self.refs = []

    def init(self):
        # find geometry
        table = findNode("tisch")
        table2 = findNode("tisch2")

        key1 = vrKey(Key_1)
        self.refs.append(key1)
        key1.connect(table.setActive, false)

        table2.setActive(False)