Python imported functions

Python imported functions

f.grz
Contributor Contributor
739 Views
2 Replies
Message 1 of 3

Python imported functions

f.grz
Contributor
Contributor

Hello guys,

 

i have a python script, that imports bare functions from another python file.  The file looks like:

 

from vrKernelServices import *
[...]
def allToMR():
vrSessionService.sendPython("MRmode()")

 

This throws me an error:

File "[...]VRtools.py", line 173, in allToMR

vrSessionService.sendPython("MRmode()")

TypeError: descriptor 'sendPython' requires a 'vrKernelServices.vrSessionService' object but received a 'str'

 

Makes no sense to me, because the code is running fine if i do not import it from the file, but run it for example in a variant Set. Also the constructor of 'sendPython' accepts only a str...

 

Any ideas?

0 Likes
Accepted solutions (1)
740 Views
2 Replies
Replies (2)
Message 2 of 3

chr33z
Advocate
Advocate
Accepted solution

Hi there!

 

Can you try remove your import

from vrKernelServices import *

 

When you import python script via a scriptplugin or a module, importing from vrKernelServices seems to create some weird name clashes in the API. When working with API v2 you do generally not need to import the modules you use.

 

Cheers!

Message 3 of 3

f.grz
Contributor
Contributor

Hmm this magically works - really sounds like a weird nameclash...

I still had to import some functionless enumeratorclasses, which is even more strange.

from vrKernelServices import vrVRInputDeviceTypes
from vrKernelServices import vrXRealityTypes 

 But it works, so thanks for your help!

0 Likes