Import own Python extensions¶
import.py¶
1# © 2024 Autodesk, Inc. All rights reserved.
2
3print("Executing import script!")
4
5# This small example shows how to write your own python modules.
6# The imported module is located in vred/lib/python/myextension.py
7# You have to import there all the vred extension modules on your own,
8# only for the main script this is done by vred automaticly!
9
10basedir = getFileIOBaseDir()
11
12import myextension
13
14loadGeometry("$VRED_EXAMPLES/geo/teddy.osb")
15updateScene()
16calcVertexNormals()
17
18# add the script path to the python search path so
19# you can put the myextension.py module also into
20# the same directory as your main script file.
21import sys
22sys.path.insert(0, basedir)
23
24ext = myextension.myextension()
25ext.init()
myextension.py¶
1
2from vrScenegraph import *
3from vrController import *
4from vrKey import *
5
6class myextension:
7 def __init__(self):
8 self.refs = []
9
10 def init(self):
11 # find geometry
12 table = findNode("tisch")
13 table2 = findNode("tisch2")
14
15 key1 = vrKey(Key_1)
16 self.refs.append(key1)
17 key1.connect(table.setActive, false)
18
19 table2.setActive(False)