◯ This is the simplest rotation method.
import bpy
#Contains various things necessary for calculation
import math
#Function to add a cube
bpy.ops.mesh.primitive_cube_add(
scale=(1, 1, 1),
#Add argument
#math.pi is 180 degrees, so math.pi * 1/6 = 30(Every time)
#Rotate 30 degrees around the X axis
rotation = (math.pi*1/6,0,0)
)
◯ We will shift them little by little.
import bpy
import math
#Iterate 100 times
for i in range(0,100):
bpy.ops.mesh.primitive_cube_add(
#Move up little by little
location=(0, 0, i/50),
scale=(1, 1, 0.05),
#180 * i * 36(Every time)Shift one by one
rotation = (0, 0, math.pi*i*10/360)
)
◯ It is an application of the above code.
import bpy
import math
#Create a variable called material yourself(material means material)
material = bpy.data.materials.new('Red')
#Define color(R,G,B,A)
material.diffuse_color = (1.0, 0.0, 0.0, 1.0)
#Repeat 100 times
for i in range(0,100):
bpy.ops.mesh.primitive_cube_add(
#Move up little by little
location=(0, 0, i/50),
scale=(1, 1, 0.05),
#Rotate little by little
rotation = (0, 0, math.pi*i*10/360)
)
#Add your own defined color to the object(append means append)
bpy.context.object.data.materials.append(material)
import bpy
#Function to add a torus
bpy.ops.mesh.primitive_torus_add(
location=(0, 0, 0),
major_radius=1.0,
minor_radius=0.01,
rotation=(0, 0, 0)
)
#Shrink in the Y-axis direction
bpy.ops.transform.resize(value=(1, 0.3, 1))
◯ It is a method to rotate after making a shape.
import bpy
import math
for i in range(0,36):
bpy.ops.mesh.primitive_torus_add(
location=(0, 0, 0),
major_radius=1.0,
minor_radius=0.01,
)
#Shrink in the Y-axis direction
bpy.ops.transform.resize(value=(1, 0.3, 1))
#Rotate around the Z axis
bpy.ops.transform.rotate(value=math.pi*i*10/360,orient_axis='Z')
◯ After rotating around one axis, it is rotated around another axis.
import bpy
import math
#Material definition
material = bpy.data.materials.new('Red')
material.diffuse_color = (1.0, 0.0, 0.0, 1.0)
for i in range(0,36):
for j in range(0,36):
bpy.ops.mesh.primitive_torus_add(
location=(0, 0, 0),
major_radius=1.0,
minor_radius=0.01,
)
#Shrink in the Y-axis direction
bpy.ops.transform.resize(value=(1, 0.3, 1))
#Rotate around the Z axis
bpy.ops.transform.rotate(value=math.pi*j*10/360,orient_axis='Z')
#Rotate around the Y axis
bpy.ops.transform.rotate(value=math.pi*i*10/360,orient_axis='Y')
#Use your own defined red
bpy.context.object.data.materials.append(material)
import bpy
#Contains various things necessary for calculation
import math
#Function to add a cube
bpy.ops.mesh.primitive_cube_add(
scale=(1, 1, 1),
#Add argument
#math.pi is 180 degrees, so math.pi * 1/6 = 30(Every time)
#Rotate 30 degrees around the X axis
rotation = (math.pi*1/6,0,0)
)
import bpy
import math
#Iterate 100 times
for i in range(0,100):
bpy.ops.mesh.primitive_cube_add(
#Move up little by little
location=(0, 0, i/50),
scale=(1, 1, 0.05),
#180 * i * 36(Every time)Shift one by one
rotation = (0, 0, math.pi*i*10/360)
)
import bpy
import math
#Create a variable called material yourself(material means material)
material = bpy.data.materials.new('Red')
#Define color(R,G,B,A)
material.diffuse_color = (1.0, 0.0, 0.0, 1.0)
#Repeat 100 times
for i in range(0,100):
bpy.ops.mesh.primitive_cube_add(
#Move up little by little
location=(0, 0, i/50),
scale=(1, 1, 0.05),
#Rotate little by little
rotation = (0, 0, math.pi*i*10/360)
)
#Add your own defined color to the object(append means append)
bpy.context.object.data.materials.append(material)
import bpy
#Function to add a torus
bpy.ops.mesh.primitive_torus_add(
location=(0, 0, 0),
major_radius=1.0,
minor_radius=0.01,
rotation=(0, 0, 0)
)
#Shrink in the Y-axis direction
bpy.ops.transform.resize(value=(1, 0.3, 1))
import bpy
import math
for i in range(0,36):
bpy.ops.mesh.primitive_torus_add(
location=(0, 0, 0),
major_radius=1.0,
minor_radius=0.01,
)
#Shrink in the Y-axis direction
bpy.ops.transform.resize(value=(1, 0.3, 1))
#Rotate around the Z axis
bpy.ops.transform.rotate(value=math.pi*i*10/360,orient_axis='Z')
import bpy
import math
#Material definition
material = bpy.data.materials.new('Red')
material.diffuse_color = (1.0, 0.0, 0.0, 1.0)
for i in range(0,36):
for j in range(0,36):
bpy.ops.mesh.primitive_torus_add(
location=(0, 0, 0),
major_radius=1.0,
minor_radius=0.01,
)
#Shrink in the Y-axis direction
bpy.ops.transform.resize(value=(1, 0.3, 1))
#Rotate around the Z axis
bpy.ops.transform.rotate(value=math.pi*j*10/360,orient_axis='Z')
#Rotate around the Y axis
bpy.ops.transform.rotate(value=math.pi*i*10/360,orient_axis='Y')
#Use your own defined red
bpy.context.object.data.materials.append(material)
English words | Japanese translation |
---|---|
import | to import/to obtain |
math | Math |
mesh | A set of vertices, edges, and faces |
scale | size |
primitive | Primitive |
add | to add |
rotation | rotation |
pi | π( =180 degrees) |
range | width |
cube | cube |
material | Material |
diffuse | Diffusion, scattering |
context | Context, environment |
object | Things, objects |
data | information |
append | Add, add |
major | big |
minor | small |
radius | radius |
transform | conversion |
resize | Resize |
axis | axis |
orient | direction |
rotate | Rotate |
rotation | rotation |
value | value |
location | Position, coordinates |
operation | Operation, operation |
Recommended Posts