Hi all!
I've written this little script which lets you move the active object around with console commands, to test out the capabilities of the Python API.
| Code: |
import bpy
ao = bpy.context.active_object
s = ''
while s != 'done':
s = input('?:')
if s == 'x+':
ao.location.x += 1
elif s == 'x-':
ao.location.x -= 1
elif s == 'y+':
ao.location.y += 1
elif s == 'y-':
ao.location.y -= 1
elif s == 'z+':
ao.location.z += 1
elif s == 'z-':
ao.location.z -= 1
elif s == 'reset':
ao.location = [0, 0, 0] |
However, my only problem is, that it only appends changes after the script has terminated, while I want something like an "interactive mode". I want to develop an addon that lets you use a WiiMote to capture 3D movement which can be used for animations, or just moving objects around (and of course it would be something constantly running and looking for input).
Any ideas?
integrating new blender input devices such as a wiimote is something, which should be coded in c/c++
with python, the only way to run something interactively is a modal operator (see code templates in text editor)
you can also react on certain events by using bpy.app.handlers, but it's pretty limited
you should not try to thread a python script, to keep blender running normal while a py script does changes to blender data in the background. This is not officially supported and will crash blender sooner or later.
_________________
I'm sitting, waiting, wishing, building Blender in superstition...