import bpy
verts = [(0,0,0),(0,1,0),(1,0,0),(1,1,0)]
edges = [(0,1),(1,3),(3,2),(2,0)]#参数为顶点的索引
faces = [(0,1,3,2)]#参数为顶点的索引
mesh = bpy.data.meshes.new('Pyramid_Mesh')
mesh.from_pydata(verts, edges,faces)
mesh.update()
pyramid = bpy.data.objects.new('Pyramid', mesh)
scene = bpy.context.scene
#scene.objects.link(pyramid)
bpy.context.scene.collection.objects.link(pyramid)

verts = [(0,0,0),(0,1,0),(1,0,0),(1,1,0)]
edges = [(0,1),(1,3),(3,2),(2,0)]#参数为顶点的索引
faces = [(0,1,3,2)]#参数为顶点的索引
mesh = bpy.data.meshes.new('Pyramid_Mesh')
mesh.from_pydata(verts, edges,faces)
mesh.update()
pyramid = bpy.data.objects.new('Pyramid', mesh)
scene = bpy.context.scene
#scene.objects.link(pyramid)
bpy.context.scene.collection.objects.link(pyramid)
