#THIS SCRIPT WORKS WITH BLENDER 2.8 AND ABOVE.
import bpy
from math import sin,cos,pi
radius=100
deg=2*pi
#TO DELETE ALL EXISTING OBJECTS
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_by_type(type='MESH')
bpy.ops.object.delete(use_global=False)
for t in range (0,360):
#RED
z=radius*sin(t*deg/360)
x=t
y=0
bpy.ops.mesh.primitive_cube_add(location=(x,y,z))
bpy.ops.transform.resize(value=(0.9,0.9,0.9))
obj_matl=bpy.data.materials.new("obj_clr")
obj_matl.diffuse_color=(1,0,0,1)
mesh=bpy.context.object.data
mesh.materials.clear()
mesh.materials.append(obj_matl)
#YELLOW
z=radius*sin(t*deg/360)
x=t+120
y=0
bpy.ops.mesh.primitive_cube_add(location=(x,y,z))
bpy.ops.transform.resize(value=(0.9,0.9,0.9))
obj_matl=bpy.data.materials.new("obj_clr")
obj_matl.diffuse_color=(1,0.6,0,1)
mesh=bpy.context.object.data
mesh.materials.clear()
mesh.materials.append(obj_matl)
#BLUE
z=radius*sin(t*deg/360)
x=t+240
y=0
bpy.ops.mesh.primitive_cube_add(location=(x,y,z))
bpy.ops.transform.resize(value=(0.9,0.9,0.9))
obj_matl=bpy.data.materials.new("obj_clr")
obj_matl.diffuse_color=(0,0,1,1)
mesh=bpy.context.object.data
mesh.materials.clear()
mesh.materials.append(obj_matl)
The wave form generated by the script can be seen by clicking on the link given below:
No comments:
Post a Comment