Hi, I am trying to control Blender from an external python script using xmlrpc in a simple script:
import bpy
from xmlrpc.server import SimpleXMLRPCServer as Server
from threading import Thread
def get_data(n):
print("Size: %s" % n)
print(bpy.context.active_object.active_material)
class TestServer():
def __init__(self):
at = Thread(target=self.serve, args=()).start()
def serve(self):
print("Serving")
srv = Server(("localhost", 5017), allow_none=True)
srv.register_function(get_data)
srv.serve_forever()
S = TestServer()
It can receive and print the incoming data corrently, but it cannot print the active object’s material (2nd line of the get_data function). The client brings up this error message:
<class ‘AttributeError’>:‘Context’ object has no attribute ‘active_object’">
Is it a problem with the thread I started for the xmlrpc server?
How can I solve it?
Thanks!