Error in user YAML: (<unknown>): found a tab character that violate indentation while scanning a plain scalar at line 3 column 3
---
- oeasy Python 0733
- 这是 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`
---- 添加100个采样点
import bpy
bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete()
for mesh in bpy.data.meshes:
bpy.data.meshes.remove(mesh)
mesh = bpy.data.meshes.new('sine wave')
sample = 100
mesh.vertices.add(sample)
mesh.edges.add(sample - 1)
for i in range(sample):
current_vertex = mesh.vertices[i]
current_vertex.co = (0, i, 1)
obj = bpy.data.objects.new('sine wave',mesh)
bpy.context.collection.objects.link(obj)
- 看不到这些点
- 把100个点
- 连成99个线段
import bpy
bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete()
for mesh in bpy.data.meshes:
bpy.data.meshes.remove(mesh)
mesh = bpy.data.meshes.new('sine wave')
sample = 100
mesh.vertices.add(sample)
mesh.edges.add(sample - 1)
for i in range(sample):
current_vertex = mesh.vertices[i]
current_vertex.co = (0, i, 1)
obj = bpy.data.objects.new('sine wave',mesh)
bpy.context.collection.objects.link(obj)
- 选中mesh
- 添加修改器
- skin
- 观察效果
- 找到代码
import bpy
bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete()
for mesh in bpy.data.meshes:
bpy.data.meshes.remove(mesh)
mesh = bpy.data.meshes.new('sine wave')
sample = 100
mesh.vertices.add(sample)
mesh.edges.add(sample - 1)
for i in range(sample):
current_vertex = mesh.vertices[i]
current_vertex.co = (0, i, 1)
if i < sample -1 :
mesh.edges[i].vertices = (i, i+1)
obj = bpy.data.objects.new('sine wave',mesh)
bpy.context.collection.objects.link(obj)
obj.modifiers.new(type="SKIN",name="skin")
- length 整体长度
- height 振幅
- sample 采样数字
- step 步长
import bpy
import math
bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete()
for mesh in bpy.data.meshes:
bpy.data.meshes.remove(mesh)
mesh = bpy.data.meshes.new('sine wave')
sample = 500
length = 30
height = 3
step = length / sample
mesh.vertices.add(sample)
mesh.edges.add(sample - 1)
for i in range(sample):
value = i * step
current_vertex = mesh.vertices[i]
current_vertex.co = (0, value, height * math.sin(value))
if i < sample -1 :
mesh.edges[i].vertices = (i, i+1)
obj = bpy.data.objects.new('sine wave',mesh)
bpy.context.collection.objects.link(obj)
obj.modifiers.new(type="SKIN",name="skin")
- 本文来自 oeasy Python 系统教程。
- 想完整、扎实学 Python,
- 搜索 oeasy 即可。





