[Bf-python] Polling a device in Bpy?

Florian Lier blender at icram.de
Wed Jun 17 09:59:15 CEST 2009


Hey Toni,

I'm looking forward to read data from a VICON System, which records and
sends data over the network (another topic ^^)

For early research I need to assure that I can run a function/script
which reads data periodically from "somewhere else" and then redraws
the 3D-Window

IMPORTANT:

I cannot use the GameEngine - because I need to relocate
an "Empty" which is the target for an IK Chain. Changing
the IK Chain / live / in the BGE isn't possible afaik. You can
just rot/loc/size the whole Armature which isn't really usefull
here. Correct me if I'm wrong.

"if it's ok for the script to stay running all the time, then you're fine."

So, if the script is running in the script window, let's assume with
some buttons, sliders and so on...Can I press a toggle button which
set's a toggle value and automagically read some data, redraw the
3D window until I press the toggle button again?

Maybe I didn't mention that I am, in fact, QUITE new to Blender.
I've learnt it from scratch  like two months ago...

Thanks a million, Florian


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
>
>
>   
>>  pseudo code
>>  ----------------------------------------------
>>  if button1 state = "down":
>>       
>> poll.mydevice(cube.setLocation(mydevice.valA,mydevice.valB,mydevice.val 
>> C))
>>      Blender.Redraw()
>>  else
>>      print "No data avail"
>>  ----------------------------------------------
>>
>>  Is there another apporach? Like looping parts of the script?
>>  The problem is, functions like while(true) or for x in  
>> range(10000000): sleep(0.5)
>>  freezing the script, thus Blender too.
>>
>>  Thank you, cheers Florian
>>
>>
>>
>>
>>  _______________________________________________
>> Bf-python mailing list
>> Bf-python at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-python
>>     
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20090617/df80879a/attachment.html>


More information about the Bf-python mailing list