Error in user YAML: (<unknown>): could not find expected ':' while scanning a simple key at line 3 column 1
---
- oeasy Python 0734
- 这是 oeasy 系统化 Python 教程,从基础一步步讲,扎实、完整、不跳步。愿意花时间学,就能真正学会。
本教程同步发布在:
个人网站: `https://oeasy.org`
蓝桥云课: `https://www.lanqiao.cn/courses/3584`
GitHub: `https://github.com/overmind1980/oeasy-python-tutorial`
Gitee: `https://gitee.com/overmind1980/oeasypython`
---import bpy
def clear_scene():
bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete()
def create_ball():
mat = bpy.data.materials.new('orange')
color = (1, 0.2, 0.2, 1)
mat.diffuse_color = color
ball = bpy.data.objects.new("ball", None)
bpy.data.collections["Collection"].objects.link(ball)
bpy.ops.mesh.primitive_uv_sphere_add()
head = bpy.context.object
head.location = (0,0,2.5)
head.data.materials.append(mat)
head.parent = ball
ball.location = (0, 0, 0)
ball.keyframe_insert(data_path="location", frame=1)
ball.location = (0, 2.5, 5)
ball.keyframe_insert(data_path="location", frame=10)
ball.location = (0, 5, 0)
ball.keyframe_insert(data_path="location", frame=20)
ball.location = (0, 5, -1)
ball.keyframe_insert(data_path="location", frame=30)
def create_kuang():
mat = bpy.data.materials.new('blue')
color = (0, 0, 1, 1)
mat.diffuse_color = color
kuang= bpy.data.objects.new("kuang", None)
bpy.data.collections["Collection"].objects.link(kuang)
bpy.ops.mesh.primitive_torus_add()
head = bpy.context.object
head.location = (0,5,2.5)
head.data.materials.append(mat)
head.parent = kuang
def create_plane():
bpy.ops.mesh.primitive_plane_add()
plane = bpy.context.object
plane.scale = (10,10,1)
def create_camera():
bpy.ops.object.camera_add()
camera = bpy.context.object
camera.location = (25, 5, 2.5)
camera.rotation_euler = (1.5708,0,1.5708)
bpy.context.scene.camera = camera
def create_spot():
bpy.ops.object.light_add(type='SPOT')
spot = bpy.context.object
spot.location = (-1.5, -3.5, 12)
spot.rotation_euler = (0.5, 0.3, -1)
spot.data.energy = 2048
def render():
bpy.context.scene.frame_end = 30
bpy.context.scene.render.resolution_x = 200
bpy.context.scene.render.resolution_y = 150
bpy.context.scene.render.resolution_percentage = 50
bpy.context.scene.render.engine = 'CYCLES'
bpy.context.scene.render.filepath = "/home/shiyanlou/Code/o"
bpy.ops.render.render(animation=True)
clear_scene()
create_kuang()
create_ball()
create_plane()
create_camera()
create_spot()
render()
- 本文来自 oeasy Python 系统教程。
- 想完整、扎实学 Python,
- 搜索 oeasy 即可。