Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- from math import sqrt
- # Set the dimensions of the HCP pattern
- dim_x = 5
- dim_y = 5
- dim_z = 5
- # Set the radius of the spheres
- radius = 1
- # Set the distance between the spheres
- spacing = radius * sqrt(2)
- # Set the starting position for the first sphere
- start_x = -dim_x * spacing / 2
- start_y = -dim_y * spacing / 2
- start_z = -dim_z * spacing / 2
- # Create a list to store the spheres
- spheres = []
- # Create the spheres
- for i in range(dim_x):
- for j in range(dim_y):
- for k in range(dim_z):
- x = start_x + i * spacing
- y = start_y + j * spacing
- z = start_z + k * spacing
- if (i + j + k) % 2 == 0:
- bpy.ops.mesh.primitive_uv_sphere_add(location=(x, y, z), radius=radius)
- spheres.append(bpy.context.active_object)
Advertisement
Add Comment
Please, Sign In to add comment