教程

QA

Python控制台输出乱码

在py脚本添加# -*- coding: utf-8 -*-

Python脚本

四棱锥

  1. # -*- coding: utf-8 -*-
  2. import bpy
  3. #Define vertices, faces, edges
  4. verts = [(0,0,0),(0,5,0),(5,5,0),(5,0,0),(2.5,2.5,4.5)]
  5. faces = [(0,1,2,3), (0,4,1), (1,4,2), (2,4,3), (3,4,0)]
  6. #Define mesh and object
  7. mesh = bpy.data.meshes.new("Cube")
  8. object = bpy.data.objects.new("Cube", mesh)
  9. #Set location and scene of object
  10. object.location = bpy.context.scene.cursor.location
  11. bpy.context.scene.collection.objects.link(object)
  12. #Create mesh
  13. mesh.from_pydata(verts,[],faces)
  14. mesh.update(calc_edges=True)

20241012 收藏的教程 - 图1