There is a Python console!
Why a Python tutorial here too?
Geometry Generate Geometry with a Python script.
import bpy
#Remove default Cube
def delete_all():
for item in bpy.context.scene.objects:
bpy.context.scene.objects.unlink(item)
for item in bpy.data.objects:
bpy.data.objects.remove(item)
for item in bpy.data.meshes:
bpy.data.meshes.remove(item)
for item in bpy.data.materials:
bpy.data.materials.remove(item)
delete_all()
#Define vertex coordinates
coords=[
(-1.0, -1.0, -1.0),
( 1.0, -1.0, -1.0),
( 1.0, 1.0, -1.0),
(-1.0, 1.0, -1.0),
( 0.0, 0.0, 1.0)
]
#Define a face using this subscript
#Each face is defined by a sequence of four integers
#Triangular face must have the same first and fourth vertices
faces=[
(2,1,0,3),
(0,1,4,0),
(1,2,4,1),
(2,3,4,2),
(3,0,4,3)
]
#Create a new mesh
me = bpy.data.meshes.new("PyramidMesh")
#Create an object with a mesh
ob = bpy.data.objects.new("Pyramid", me)
#Place the object at the 3D cursor position
ob.location = bpy.context.scene.cursor_location
#Link objects to scenes
bpy.context.scene.objects.link(ob)
#Fill the vertices, edges, and faces of the mesh
me.from_pydata(coords,[],faces)
#Update mesh with new data
me.update(calc_edges=True)
Do not use Japanese for comments (even comments are garbled)
Recommended Posts