[Bf-python] Polling a device in Bpy?
Theo de Ridder
theo.de.ridder at planet.nl
Wed Jun 17 10:21:13 CEST 2009
On 17 jun 2009, at 09:36, Toni Alatalo wrote:
> On Jun 17, 2009, at 10:30 AM, Florian Lier wrote:
>
>> I need to know if its possible to poll a device constantly in a
>> py-script like this
>
> yes, polling works like it normally does. so you can e.g. use select()
> to read from a socket in a non-blocking manner, or use some python
> module that gives polling access to your device.
>
> the question is how you need to execute the code. if it's ok for the
> script to stay running all the time, then you're fine. if you'd like
> it
> to have it like a scriptlink, i.e. just in the scene and not running
> otherwise, there is currently no 'always' scriptlink that would run
> periodically. 2.5 should solve this too with the new event internals.
>
> ~Toni
based on an idea of Pablo Martin I used in the past the following
scene redraw scriptlink:
----------------
import Blender as B
B.sys.sleep(100)
winid1 = B.Window.GetAreaID()
B.Window.QAdd(winid1, B.Draw.REDRAW, 0, 1)
try:
winid2 = B.boardWindow.winid
B.Window.QAdd(winid2, B.Draw.TIMER0, 0, 1)
except:
pass
-------------------
here winid2 is the window-id of a running script
that will receive a TIMER0 event each 100 ms;
I based on this asynchronous socket connections for
full transparent remote python data access and post-mortem
debugging; however what you do in your script should remain
thread-save (so full remote debugging was not possible (waiting for
2.5))
~Theo
More information about the Bf-python
mailing list