教程
QA
Python控制台输出乱码
在py脚本添加# -*- coding: utf-8 -*-
Python脚本
四棱锥
# -*- coding: utf-8 -*-
import bpy
#Define vertices, faces, edges
verts = [(0,0,0),(0,5,0),(5,5,0),(5,0,0),(2.5,2.5,4.5)]
faces = [(0,1,2,3), (0,4,1), (1,4,2), (2,4,3), (3,4,0)]
#Define mesh and object
mesh = bpy.data.meshes.new("Cube")
object = bpy.data.objects.new("Cube", mesh)
#Set location and scene of object
object.location = bpy.context.scene.cursor.location
bpy.context.scene.collection.objects.link(object)
#Create mesh
mesh.from_pydata(verts,[],faces)
mesh.update(calc_edges=True)