Hi i'm thying threading with bpy this is my code:
import bpy
import threading
class Cubes(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
scale = 0.2
space = 0.2
max_range = 6
for i in range(0, max_range):
bpy.ops.mesh.primitive_cube_add(radius = 1, location=(0, 0, 1))
bpy.ops.object.origin_set( type="ORIGIN_CURSOR" )
bpy.context.active_object.scale.x = scale
bpy.context.active_object.scale.y = scale
bpy.context.active_object.scale.z = 5
bpy.ops.object.transform_apply(location = False, rotation = False, scale = True)
bpy.context.active_object.location = (((i*scale*2)+(i*space))-(((max_range*scale*2)+(max_range*space)))/2,0,0)
return
t = Cubes()
t.start()
but when i run this the console give me this error:
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender\2.75\python\lib\threading.py", line 921, in _bootstrap_inner
self.run()
File "C:\Users\Davide\Desktop\Sound_Visualizer.blend\Sound_Visualizer_Circular.py", line 40, in run
AttributeError: 'Context' object has no attribute 'active_object'
Can someone help me?