Search This Blog

Monday 20 December 2021

BPY SCRIPT TO POSITION AN OBJECT AT RANDOM LOCATION.

 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:

TO MIRROR ARMATURE BONES ON X AXIS 1. Assume that we are making a human rig in standing position. 2. Set the view to front view. 3. Create t...