create cube in blender using python codes

Published: 04 April 2023
on channel: Rover
193
5

create cube in blender using python codes
#shorts

Python Code

import bpy

Define cube vertices
verts = [(1, 1, -1), (1, -1, -1), (-1, -1, -1), (-1, 1, -1), (1, 1, 1), (1, -1, 1), (-1, -1, 1), (-1, 1, 1)]

Define cube edges
edges = [(0, 1), (1, 2), (2, 3), (3, 0), (4, 5), (5, 6), (6, 7), (7, 4), (0, 4), (1, 5), (2, 6), (3, 7)]

Define cube faces
faces = [(0, 1, 2, 3), (4, 5, 6, 7), (0, 4, 7, 3), (1, 5, 4, 0), (2, 6, 5, 1), (3, 7, 6, 2)]

Create mesh and object
mesh = bpy.data.meshes.new("Cube")
object = bpy.data.objects.new("Cube", mesh)

Set location and add to scene
object.location = bpy.context.scene.cursor.location
bpy.context.scene.collection.objects.link(object)

Create mesh from data
mesh.from_pydata(verts, edges, faces)
mesh.update()


On this page of the site you can watch the video online create cube in blender using python codes with a duration of hours minute second in good quality, which was uploaded by the user Rover 04 April 2023, share the link with friends and acquaintances, this video has already been watched 193 times on youtube and it was liked by 5 viewers. Enjoy your viewing!