I have a json file that is dynamically generated on a server. I'm currently using a python program to copy it locally. I have a script that can check the json file from blender, and change my object rotation, but I can't seem to make it work periodically (like, I'd like the script to run every 0.2 sec).
import json import bpy import time def doit(): with open('/somepath/blendjson.json') as data_file: data = json.load(data_file) coordx = float(data['coordx'])/5 coordy = float(data['coordy'])/5 bpy.ops.transform.rotate(value=coordx, axis=(-1, -0, -0), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.transform.rotate(value=coordy, axis=(-0, -1, -0), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) while True: doit() time.sleep(0.2)
This script doesn't do anything in blender. When I kill it in the terminal, it throws an empty error, with nothing following it : "Error: Python script fail, look in the console for now..."
The issue here seems to be that time.sleep blocks the script. I can only see the results when I kill it.
I'm looking for an alternative to time.sleep that does not stop the script. I want to run the def every 200 ms, and see the result in real time.