如何在python http服务器脚本运行时解锁Blender UI?

时间:2019-04-30 14:48:06

标签: python blender

我想使用python http.server将对象从搅拌器返回到其他应用程序,同时将对象移动到搅拌器上。但是Blender ui冻结,直到python脚本完成。有什么方法可以解锁搅拌器对象?

我在Ubuntu上使用Blender 2.8。我尝试使用过程,但没有什么不同。

from http.server import HTTPServer, BaseHTTPRequestHandler
import bpy


class Serv(BaseHTTPRequestHandler):

    def do_GET(self):
        if self.path == '/location':
            self.send_response(200, 'message')
            self.send_header('Content-Type', 'application/json')
            self.end_headers()
            l = bpy.data.objects["Cube"].location
            x = "x : " + str(l[0]) + ", y : " + str(l[1]) + ", Z : " + str(l[2])
            self.wfile.write(bytes(x, 'utf-8'))

httpd = HTTPServer(('localhost', 8099), Serv)
httpd.serve_forever()

0 个答案:

没有答案
相关问题