H3D API  2.4.1
How to use H3DAPI from python.

The Basics

The PythonScript node is a binding to the Python scripting language, which can be used to e.g. modify scenes and handle events. In order to use Python a PythonScript node have to be added to the scenegraph. The PythonScript node specifies an url to where the actual Python code is located. So if there is a simle Python file named Hello.py which contains:

print "Hello"

You can get this code to execute by adding a PythonScript node to your scenegraph. This can be done by specifying it directly in an x3d file, e.g.

<Scene>
  <PythonScript url="Hello.py" />
</Scene>

If you use H3DLoad on the x3d file the Python code should execute and "Hello" should be printed to the command prompt.

H3D API also adds its own types and field types and classes to be used from python. All these are defined in the H3DInterface module. In order to get access to these types and classes you have to import the Python module named H3DInterface. This contains all H3D specific Python bindings. It can be imported by writing

from H3DInterface import *

in your Python file.

Content of H3DInterface module

Doxygen documentation for python bindings can be found here.