# Is there a timeout/max capacity in blender's phyton scripts?

I can't figure out if there's something wrong with blender or my script. So far I have this little code, which does its job if the file which is parsing is not SO big:

import bpy
fh = open('coordinates.txt')

for line in fh:
coo = line.split()
x = float(coo[0])
y = float(coo[1])
z = float(coo[2])
bpy.ops.transform.resize(value=(1, 1, 1))


When I try coordinates.txt with few lines, it works and it creates the cubes, but when I do it with its original size of around 215000 lines, Blender stops responding and it stays like that forever.

Has anyone any idea of what I can do to avoid it? (Reducing the file's lines is not an option )

Btw, coordinates.txt has this format

335.0091 2433.163 -126.9688
351.7849 2352.089 -126.9688
-493 -808 128.5834
-1076 -843 132.8153
160.123 2369.68 -126.9688
-760.663 -836.174 132.07
182.9523 2438.389 -126.9688
-332 -754 88.59317
259.0002 2480.136 -126.9688
-857.507 -738.361 130.3733
338.3209 2430.226 -126.9688
353.1722 2349.083 -126.9688
-493 -808 128.5834
-1076 -843 132.8153

• check this max verts count and if you can upload the file i'll test it on my system too – Chebhou Jan 10 '15 at 16:46
• You may be interested in the timing tests here that compare creating objects different ways. – sambler Jan 11 '15 at 2:30

Your srcipt is fine, and blender is not timing out, but rather you have found a limitation of blender. Blender is not good at displaying many objects, 250,000 different cubes will crash blender.
Try adding 3 array modifiers to a cube, to generate 250,00 cubes, then go into edit mode and separate by Loose Parts (blender will crash.)

Instead of adding a cube at each coordinate, create a mesh with all the coordinates as vertices. So each coordinate is represented as a vertex.

import bpy
fh = open('coordinates.txt')

# A list of the locations of the cubes
vertices = []

for line in fh:
coo = line.split()
x = float(coo[0])
y = float(coo[1])
z = float(coo[2])

# Instead of adding a cube, append the location of the cube to vertices
vertices.append((x, y, z))

# Make a new mesh and set its vertices
mesh = bpy.data.meshes.new('verts')
mesh.from_pydata(vertices, [], [])

# Make an object for the mesh
object = bpy.data.objects.new('verts', mesh)

• Woah, thank you for your answer, it is really helpful, but while trying your script, I get in this line mesh = bpy.data.meshes.new('verts') an error: Invalid syntax – Rubén Rincón Blanco Jan 10 '15 at 17:49