CG Trader

Simple 3D Cube with a phase
by CG Trader
Last crawled date: 2 years, 12 months ago
This Cube with a side relationship of 3.0 to 2.0 to 1.0 with a phase on one side of 0.1 can easily be used as a base to construct more complex models. I constructed it with a python script in blender therefore i'm able to construct easily all relationships needed. Here is the script: import bpy from bpy import data as D, context as C import bmesh
import math
import mathutils
from mathutils import Vector
from math import radians length = 3.0
width = 2.0
height = 1.0 bevel_angle = 30
bevel_z = 0.1
bevel_xy = bevel_z / math.tan(radians(bevel_angle)) vec_01 = mathutils.Vector((-length / 2, -width / 2, 0.0))
vec_02 = mathutils.Vector((-length / 2, width / 2, 0.0))
vec_03 = mathutils.Vector((length / 2, -width / 2, 0.0))
vec_04 = mathutils.Vector((length / 2, width / 2, 0.0)) vec_05 = mathutils.Vector((-length / 2, -width / 2, height - bevel_z))
vec_06 = mathutils.Vector((-length / 2, width / 2, height - bevel_z))
vec_07 = mathutils.Vector((length / 2, -width / 2, height - bevel_z))
vec_08 = mathutils.Vector((length / 2, width / 2, height - bevel_z)) vec_09 = mathutils.Vector((-length / 2 + bevel_xy, -width / 2 + bevel_xy, height))
vec_10 = mathutils.Vector((-length / 2 + bevel_xy, width / 2 - bevel_xy, height))
vec_11 = mathutils.Vector((length / 2 - bevel_xy, -width / 2 + bevel_xy, height))
vec_12 = mathutils.Vector((length / 2 - bevel_xy, width / 2 - bevel_xy, height)) bm = bmesh.new() verts = [vec_01, vec_02, vec_03, vec_04, vec_05, vec_06, vec_07, vec_08, vec_09, vec_10, vec_11, vec_12] faces = [(0, 1, 3), (3, 2, 0), {0, 1, 5}, {5, 4, 0}, {2, 3, 7}, {7, 6, 2}, {0, 2, 6}, {6, 4, 0}, {1, 3, 7}, {7, 5, 1},
{4, 8, 6}, {8, 6, 10}, {5, 9, 7}, {9, 7, 11}, {4, 5, 8}, {5, 8, 9}, {6, 7, 10}, {7, 10, 11}, {8, 9, 11}, {11, 10, 8}] edges = [] mesh_name = modCube
mesh_data = D.meshes.new(mesh_name)
mesh_data.from_pydata(verts, edges, faces) corrections = mesh_data.validate(
verbose=True,
clean_customdata=True) bm = bmesh.new()
bm.from_mesh(mesh_data) bm.to_mesh(mesh_data)
bm.free()
mesh_obj = D.objects.new(mesh_data.name, mesh_data)
C.collection.objects.link(mesh_obj) bpy.ops.object.select_all(action='DESELECT')
mesh_obj.select_set(True)
bpy.context.view_layer.objects.active = mesh_obj bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.normals_make_consistent(inside=False) bpy.ops.object.editmode_toggle() geometric square simplicity geometric shape business design scripts plugins scripts plugins modelling
import math
import mathutils
from mathutils import Vector
from math import radians length = 3.0
width = 2.0
height = 1.0 bevel_angle = 30
bevel_z = 0.1
bevel_xy = bevel_z / math.tan(radians(bevel_angle)) vec_01 = mathutils.Vector((-length / 2, -width / 2, 0.0))
vec_02 = mathutils.Vector((-length / 2, width / 2, 0.0))
vec_03 = mathutils.Vector((length / 2, -width / 2, 0.0))
vec_04 = mathutils.Vector((length / 2, width / 2, 0.0)) vec_05 = mathutils.Vector((-length / 2, -width / 2, height - bevel_z))
vec_06 = mathutils.Vector((-length / 2, width / 2, height - bevel_z))
vec_07 = mathutils.Vector((length / 2, -width / 2, height - bevel_z))
vec_08 = mathutils.Vector((length / 2, width / 2, height - bevel_z)) vec_09 = mathutils.Vector((-length / 2 + bevel_xy, -width / 2 + bevel_xy, height))
vec_10 = mathutils.Vector((-length / 2 + bevel_xy, width / 2 - bevel_xy, height))
vec_11 = mathutils.Vector((length / 2 - bevel_xy, -width / 2 + bevel_xy, height))
vec_12 = mathutils.Vector((length / 2 - bevel_xy, width / 2 - bevel_xy, height)) bm = bmesh.new() verts = [vec_01, vec_02, vec_03, vec_04, vec_05, vec_06, vec_07, vec_08, vec_09, vec_10, vec_11, vec_12] faces = [(0, 1, 3), (3, 2, 0), {0, 1, 5}, {5, 4, 0}, {2, 3, 7}, {7, 6, 2}, {0, 2, 6}, {6, 4, 0}, {1, 3, 7}, {7, 5, 1},
{4, 8, 6}, {8, 6, 10}, {5, 9, 7}, {9, 7, 11}, {4, 5, 8}, {5, 8, 9}, {6, 7, 10}, {7, 10, 11}, {8, 9, 11}, {11, 10, 8}] edges = [] mesh_name = modCube
mesh_data = D.meshes.new(mesh_name)
mesh_data.from_pydata(verts, edges, faces) corrections = mesh_data.validate(
verbose=True,
clean_customdata=True) bm = bmesh.new()
bm.from_mesh(mesh_data) bm.to_mesh(mesh_data)
bm.free()
mesh_obj = D.objects.new(mesh_data.name, mesh_data)
C.collection.objects.link(mesh_obj) bpy.ops.object.select_all(action='DESELECT')
mesh_obj.select_set(True)
bpy.context.view_layer.objects.active = mesh_obj bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.normals_make_consistent(inside=False) bpy.ops.object.editmode_toggle() geometric square simplicity geometric shape business design scripts plugins scripts plugins modelling