import bpy
import math
import bmesh
import sys
from mathutils import Vector
def main():
remove_all_obj()
add_cube_1()
add_cube_2()
def add_cube_1():
bpy.ops.mesh.primitive_cube_add(
size=1.0,
align='WORLD',
location=(1.0, 2.0, 3.0),
rotation=(math.radians(0),
math.radians(0),
math.radians(0)),
scale=(3.6+0.25,
2.475,
2.7+0.25)
)
obj = bpy.context.view_layer.objects.active
return obj
def add_cube_2():
bpy.ops.mesh.primitive_cube_add(
location=( -1, -2, -3 ),
rotation=( math.pi/3, 0, 0 ) )
obj = bpy.context.view_layer.objects.active
obj.name = 'MakeCube'
obj.scale = ( 1, 1, 1 )
obj.select_set(False)
return obj
def remove_all_obj():
for col in bpy.data.collections:
for item in col.objects:
col.objects.unlink(item)
bpy.data.objects.remove(item)
for item in bpy.context.scene.collection.objects:
bpy.context.scene.collection.objects.unlink(item)
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)
if __name__ == '__main__':
main()