I’ve been using a Structure Synth->Blender->Luxrender workflow for generative art experiments, but I would love to remove Structure Synth and generate the geometry directly in Blender; thereby streamlining the workflow.
Many Structure Synth structures are composed of hundreds of thousands of primitives (usually cubes or spheres). To assess Blender’s ability to handle generation of such large numbers of primitives, I whipped up this script which generates a grid of 1600 cubes:
import bpy, time
begin = time.time()
for i in range(40):
for j in range(40):
bpy.ops.mesh.primitive_cube_add(location=(i+i*2, j+j*2, 0))
end = time.time()
print('Execution took', end-begin, 'seconds.')
Using Blender 2.58.1 64-Bit on a 2.93GHz Core 2 Duo MacBook Pro, this script output:
Execution took 170.26286101341248 seconds.
(Edit: Further runs of this script have taken about 25-30 seconds, so the 170sec initial run must have been with a higher number of cubes, or I had something running in the background.)
This was a major letdown, as coming from Structure Synth, I’m used to generating hundreds of thousands of cubes or spheres without issue. The same code translated to Eisenscript (Structure Synth’s dialect) completes instantaneously:
40 * { x 2 } 40 * { y 2 } cube
rule cube{
box
}
Can the bpy code be optimized at all? Are there ways to get closer to the metal (so to speak) than the bpy.ops.mesh.primitive_xxx operators? Or is Blender just not well-suited to this task?