I need to import a lot (more than 100) of spheres or cylinders in Blender. I have written a little function to do that. However, my machine (Bi-Xeon core duo, 4Go mem) become completely busy when the number of sphere increase.
It’s probably due to the fact that I create all the objects and after join them to a new.
I don’t know how I can avoid this.
Here the script of the function, if somebody could take a look.
def draw_spheres(line) :
global ob, me, Z_scale, point_size
ob_list = []
scn = Scene.GetCurrent()
ln = line.split()
nb_sphere = int(ln[3])
for i in range(0, nb_sphere) : # read points coordinates
line = ImodFile.readline()
ln = line.split()
no = Vector(float(ln[0]), float(ln[1]), float(ln[2])*Z_scale)
me_new = Mesh.Primitives.Icosphere(2,point_size)
ob_new = scn.objects.new(me_new,‘sphere’)
for v in me_new.verts : # translate the sphere
v.co += no
me_new.update()
ob_new.link(me_new)
ob_list.append(ob_new)
ob.join(ob_list)
for i in ob_list : scn.objects.unlink(i)