Previous Thread  Next Thread

chat icon Trying Blender as a procedural modelling tool

panekko

Posted: Tue Feb 12, 2013 12:02 pm
Joined: 12 Feb 2013
Posts: 1
Hi every one,

I'm interested in using a 3D authoring tool to generate structures algorithmically, and since Blender provides a python API i wanted to give it a try.

I managed to create a grid of cubes with different dimensions and rotations using this script:


Code:

from random import randrange
import random
import bpy

add_cube = bpy.ops.mesh.primitive_cube_add
mylayers = [False]*20
mylayers[0] = True
for indexX in range(0, 10):
    for indexY in range(0, 10):
        for indexZ in range(0, 10):       
            location = indexX, indexY, indexZ
            rotation = randrange(-10,10), randrange(-10,10), randrange(-10,10)
            dimensions = random.random(), random.random(), random.random()
            cube = add_cube(location=(location), rotation=(rotation), layers=mylayers)
            cube = bpy.context.object
            cube.dimensions = dimensions







It generates the cubes as expected, but it takes A LOT of time to do so (about 30 seconds). Is it normal to take this long? (I'm not refering to rendering but to the actual objects creation).

BTW, I'm using the nested loops for simplicity, but I have the same problem (regarding execution time) if i use a single loop and, let's say, random positions.
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group