The script below positions the monkey object at random position between _20 and +20 units along the X and Y axis. Along Z axis the location varies between -2 and +2 units.
----------------------------------------------------------------------------------------------------------------------------
'''POSITIONS MONKEY OBJECT AT RANDOM LOCATIONS BETWEEN -20 AND +20 UNITS ALONG X & Y AXIS, -2 TO +2 UNITS ALONG Z AXIS '''
import bpy
bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete(use_global=False)
from random import randint
number=200
for i in range(0,number):
x=randint(-20,20)
y=randint(-20,20)
z=randint(-2,2)
bpy.ops.mesh.primitive_monkey_add(location=(x,y,z))
----------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment