Cube Art
Cube Art
Cube Art
import pdb
import random
import math
from math import sin, cos, radians
from bpy.props import *
class MyOperator(bpy.types.Operator):
""" for cube art """
bl_idname = "object.my_operator"
bl_label = "My cube art operator"
bl_options = {'REGISTER', 'UNDO'}
# properties
spacing : FloatProperty(
name="Spacing",
description="Spacing between cubes",
default=2.1,
min=0,
max=7.0
)
cube_count : IntProperty(
name="cube count",
description="A number of cubes",
default=25,
min=1,
max=100
)
width_of_spiral : FloatProperty(
name="Width of spiral",
description="Width of the spiral",
default=1,
min=0,
max=999.0
)
height_of_spiral : FloatProperty(
name="Height of spiral",
description="Height of the spiral",
default=1,
min=0.1,
max=999.0
)
def generate_random_bright_color():
""" generates random bright color """
# Generate random RGB values between 0 and 1
r = random.random()
g = random.random()
b = random.random()
return (r, g, b)
def remove_collection(collection_name):
pdb.set_trace()
# Get the collection
collection = bpy.data.collections.get(collection_name)
return {'FINISHED'}
# Register and add to the "object" menu (required to also use F3 search "Simple
Object Operator" for quick access).
def register():
bpy.utils.register_class(MyOperator)
bpy.types.VIEW3D_MT_object.append(menu_func)
def unregister():
bpy.utils.unregister_class(MyOperator)
bpy.types.VIEW3D_MT_object.remove(menu_func)
if __name__ == "__main__":
register()
# test call
bpy.ops.object.my_operator()
import bpy
import random
SPACING = 2
def delete_cylinders():
# Iterate over all objects in the scene
for obj in bpy.context.scene.objects:
if obj.type == 'MESH' and obj.data.name.startswith('Cylinder'):
bpy.data.objects.remove(obj, do_unlink=True)
bpy.ops.object.select_all(action='DESELECT')
if hexagons is not []:
for hexagon in hexagons:
hexagon.select_set(True)
bpy.context.view_layer.objects.active = hexagons[0]
bpy.ops.object.join()
dal = 50
delete_cylinders()
for y in range(4):
rock_chunk(5 , y*dal , 0)
rock_chunk(-5 , y*dal , 0)