I am doing a complicated 3D scene model. Actually, I am using the blender GUI (not python script) to do it. Once I designed the scene, I need to move randomly an object in the scene for many times. So, I am wondering, if possible to write a python script that execute the *.blend file and then in the same script, I write lines to move randomly the object. Any suggestion?

  • $\begingroup$ do you mean "Open" by "execute" , is your workflow like this : 1-Open the blend file of the scene 2-move the object 3-do something 3-close without saving , and repeat $\endgroup$
    – Chebhou
    Jan 5, 2016 at 21:01
  • $\begingroup$ @Chebhou, I need to write a script xxx.py that include kind of execute or import of .blend file and below that a loop to move an object randomly in the scene and for example after each iteration i can save a mesh as *.stl file. $\endgroup$ Jan 5, 2016 at 21:09
  • $\begingroup$ so you have the scene blend file open, then import the object from another blend file , move the object and export each time $\endgroup$
    – Chebhou
    Jan 5, 2016 at 21:12

1 Answer 1

import bpy 
from random import randint 

# Generate 50 cubes in random locations for i in range(50):
bpy.ops.mesh.primitive_cube_add(location = [ randint( -10, 10 ) for axis in 'xyz' ])

Replace cube with your model and this should work.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .