From 8e64734c3527825672b68ac764c047f1f9081b9b Mon Sep 17 00:00:00 2001 From: CJ Satnarine <117758228+CJSatnarine@users.noreply.github.com> Date: Tue, 21 Mar 2023 12:58:09 -0400 Subject: [PATCH] Created a grid using cubes. --- Trial.py | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/Trial.py b/Trial.py index 6c68d1b..feaef46 100644 --- a/Trial.py +++ b/Trial.py @@ -1,29 +1,39 @@ #Imports. import bpy; +import random; size = 1; -xNumOfCubes = 3; -yNumOfCubes = 2; -zNumOfCubes = 0; x = y = z = size / 2; #Creating the inital cube. bpy.ops.mesh.primitive_cube_add(size = size, location = (x, y, z)); -#I need to create an algorithm that will create the cubes in the shape of a block. +# Iterate over each grid 'cell' we want a cube at. +for x in range(20): + for y in range(20): + #Set the location. + location = (x, y, z); -#Creating cubes in the X-Position. -for i in range(xNumOfCubes): - x += size; - bpy.ops.mesh.primitive_cube_add(size = size, location = (x, y, z)); + #Add the cubes. + bpy.ops.mesh.primitive_cube_add(size = size, location=location, scale=(1, 1, 1)); -#Creating cubes in the Y-Position. -for i in range(yNumOfCubes): - y += size; - bpy.ops.mesh.primitive_cube_add(size = size, location = (x, y, z)); +##Creating cubes in the X-Position. +#for i in range(xNumOfCubes): +# x += size; +# bpy.ops.mesh.primitive_cube_add(size = size, location = (x, y, z)); -#Creating cubes in the Z-Position. -for i in range(zNumOfCubes): - z += size; - bpy.ops.mesh.primitive_cube_add(size = size, location = (x, y, z)); \ No newline at end of file +##Creating cubes in the Y-Position. +#for i in range(yNumOfCubes): +# y += size; +# bpy.ops.mesh.primitive_cube_add(size = size, location = (x, y, z)); + +##Creating cubes in the Z-Position. +#for i in range(zNumOfCubes): +# z += size; +# bpy.ops.mesh.primitive_cube_add(size = size, location = (x, y, z)); + + +#Notes: +# - There is a cube that spawns amongst the grid that doesn't fit in with the rest. +# - To create the grid to spawn cubes in the z-axis, then I should create a new for loop within the nested loop to take create it in the z-axis. \ No newline at end of file