0.Subdivision Surface 1.Array 2.Bevel 3.Boolean 4.Build 5.Decimate 6.Mirror 7.Screw 8.Skin 9.Solidify 10.ShrinkWrap (11.Shape Key)
0.Subdivision Surface
import bpy
def subSurf(level = 3):
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.context.object.modifiers["Subdivision"].levels = level
bpy.ops.mesh.primitive_monkey_add()
subSurf()
1.Array
import bpy
def array(num = 5,o_x = 2,o_y = 0,o_z = 0):
bpy.ops.object.modifier_add(type='ARRAY')
array = bpy.context.object.modifiers["Array"]
array.count = num
array.relative_offset_displace[0] = o_x
array.relative_offset_displace[1] = o_y
array.relative_offset_displace[2] = o_z
bpy.ops.mesh.primitive_cube_add()
array(o_x = 5,o_y = 5,o_z = 5)
2.Bevel
import bpy
def bevel(_amount = 0.3,_segments = 1):
bpy.ops.object.modifier_add(type='BEVEL')
bevel = bpy.context.object.modifiers["Bevel"]
bevel.width = _amount
bevel.segments = _segments
bpy.ops.mesh.primitive_ico_sphere_add()
bevel()
2-1.Bevel_animation
import bpy
frame_num = 0
bpy.context.scene.frame_set(frame_num)
bpy.context.scene.frame_end = 50
bpy.ops.mesh.primitive_cube_add()
bpy.ops.object.modifier_add(type='BEVEL')
bevel = bpy.context.object.modifiers["Bevel"]
for i in range(0,2):
bevel.width = i
bevel.keyframe_insert(data_path = "width",frame = frame_num)
frame_num += 50
3.Boolean
import bpy
def boolean(obj):
bpy.ops.object.modifier_add(type='BOOLEAN')
boolean = bpy.context.object.modifiers["Boolean"]
boolean.operation = 'DIFFERENCE'
boolean.object = bpy.data.objects[obj]
bpy.ops.object.modifier_apply(modifier="Boolean")
bpy.ops.mesh.primitive_cube_add()
bpy.ops.mesh.primitive_cube_add(location = (1,1,1))
boolean("Cube")
4.Build
import bpy
def build(f):
bpy.ops.object.modifier_add(type='BUILD')
build = bpy.context.object.modifiers["Build"]
build.frame_start = f
build.use_random_order = False
build.seed = 0
bpy.ops.mesh.primitive_monkey_add()
build(f = 0)
4-1.Build_animation
import bpy
frame_num = 0
bpy.context.scene.frame_set(frame_num)
bpy.context.scene.frame_end = 120
bpy.ops.mesh.primitive_monkey_add()
bpy.ops.object.modifier_add(type='BUILD')
build = bpy.context.object.modifiers["Build"]
for i in range(0,2):
build.frame_start = 12 -i * 110
build.keyframe_insert(data_path = "frame_start",frame = frame_num)
frame_num -= 110
5.Decimate
import bpy
def decimate(limit_num):
bpy.ops.object.modifier_add(type='DECIMATE')
decim = bpy.context.object.modifiers["Decimate"]
decim.decimate_type = 'DISSOLVE'
decim.delimit = {'NORMAL'}
decim.angle_limit = limit_num
bpy.ops.mesh.primitive_monkey_add()
decimate(limit_num = 0.8)
6.Mirror
import bpy
def mirror(obj):
bpy.ops.object.modifier_add(type='MIRROR')
mir = bpy.context.object.modifiers["Mirror"]
mir.use_axis[0] = True
mir.mirror_object = bpy.data.objects[obj]
bpy.ops.mesh.primitive_monkey_add()
bpy.ops.mesh.primitive_cube_add(location = (3,0,0))
bpy.context.view_layer.objects.active = bpy.data.objects["Suzanne"]
mirror("Cube")
7.Screw
import bpy
def subSurf(level = 3):
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.context.object.modifiers["Subdivision"].levels = level
def screw(angle = 6.28,screw = 10,itr = 1,ax = 'Z'):
bpy.ops.object.modifier_add(type='SCREW')
scr = bpy.context.object.modifiers["Screw"]
scr.angle = angle
scr.screw_offset = screw
scr.iterations = 2
scr.axis = ax
bpy.ops.mesh.primitive_grid_add()
screw(itr = 2)
subSurf()
7-1.Screw_animation
import bpy
frame_num = 0
bpy.context.scene.frame_set(frame_num)
bpy.context.scene.frame_end = 120
bpy.ops.mesh.primitive_grid_add()
bpy.ops.object.modifier_add(type='SCREW')
scr = bpy.context.object.modifiers["Screw"]
_angle = 0
_screw_offset = 10
for i in range(0,2):
scr.angle = _angle
scr.screw_offset = _screw_offset
#scr.iterations = i + 1
scr.keyframe_insert(data_path = "angle",frame = frame_num)
scr.keyframe_insert(data_path = "screw_offset",frame = frame_num)
scr.keyframe_insert(data_path = "iterations",frame = frame_num)
frame_num += 110
_angle += 15
_screw_offset += 15
8.Skin
import bpy
bpy.ops.mesh.primitive_uv_sphere_add()
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.delete(type='EDGE_FACE')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.object.modifier_add(type='SKIN')
bpy.ops.transform.skin_resize(value=(0.1, 0.1, 0.1))
bpy.ops.object.mode_set(mode='OBJECT')
9.Solidify
import bpy
def solid(thick = -0.15,ofs = -1):
bpy.ops.object.modifier_add(type='SOLIDIFY')
solid = bpy.context.object.modifiers["Solidify"]
solid.thickness = thick
solid.offset = ofs
bpy.ops.mesh.primitive_monkey_add()
solid()
10.ShrinkWrap
import bpy
def subSurf(level = 3):
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.context.object.modifiers["Subdivision"].levels = level
def shrinkWrapAnim(obj):
bpy.ops.object.modifier_add(type='SHRINKWRAP')
bpy.context.object.modifiers["Shrinkwrap"].target = bpy.data.objects[obj]
bpy.ops.object.modifier_apply_as_shapekey(keep_modifier=False, modifier="Shrinkwrap")
def shapeKeyInsert(frame_num = 10,shape_value = 1):
obj = bpy.context.object
obj.active_shape_key_index = 1
for i in range(0,2):
obj.active_shape_key.value = shape_value
obj.active_shape_key.keyframe_insert(data_path = "value",frame = frame_num)
frame_num += 50
shape_value -= 1
s = 0.3
bpy.context.scene.frame_set(0)
bpy.context.scene.frame_end = 50
bpy.ops.mesh.primitive_cube_add(scale = (s,s,s))
bpy.ops.mesh.primitive_monkey_add()
subSurf()
shrinkWrapAnim("Cube")
shapeKeyInsert()
11.Shape Key
import bpy
bpy.ops.mesh.primitive_cube_add()
bpy.ops.object.shape_key_add(from_mix=False)
obj = bpy.context.object
deform_num = 2
for i in range(0,deform_num):
obj.active_shape_key_index = i + 1
obj.data.vertices[i * 2].co.z += 5
bpy.ops.object.shape_key_add(from_mix=False)
frame_num = 0
for f in range(0,deform_num + 1):
if(f == i + 1):
val = 1
else:
val = 0
obj.active_shape_key.value = val
obj.active_shape_key.keyframe_insert(data_path = "value",frame = frame_num)
frame_num += 50
Recommended Posts