Made the code have functions.
This commit is contained in:
24
Trial.py
24
Trial.py
@@ -2,6 +2,13 @@
|
||||
import bpy;
|
||||
import random;
|
||||
|
||||
# Variables:
|
||||
|
||||
size = 1; # Size of each cube.
|
||||
|
||||
x = y = z = size / 2; # Setting the x, y, and z positions.
|
||||
|
||||
|
||||
#Function to clean the scene. This removes all of the objects, collections, materials, particles, textures, images, curves, meshes, actions, nodes, and worlds from the scene.
|
||||
def cleanScene():
|
||||
# Changes the mode to object mode if it is in Edit mode.
|
||||
@@ -18,17 +25,9 @@ def cleanScene():
|
||||
bpy.ops.object.select_all(action = "SELECT");
|
||||
bpy.ops.object.delete();
|
||||
|
||||
# Calling the clean scene method.
|
||||
cleanScene();
|
||||
|
||||
# Size of each cube.
|
||||
size = 1;
|
||||
|
||||
# Setting the x, y, and z positions.
|
||||
x = y = z = size / 2;
|
||||
|
||||
# Iterate over each grid 'cell' we want a cube at.
|
||||
for x in range(20):
|
||||
def spawnGround():
|
||||
for x in range(20):
|
||||
for y in range(20):
|
||||
for z in range(1):
|
||||
# Set the location.
|
||||
@@ -49,8 +48,11 @@ for x in range(20):
|
||||
activeObject.data.materials.append(material);
|
||||
|
||||
# Change the base colour.
|
||||
materialNodes['Principled BSDF'].inputs['Base Color'].default_value = (1.0, 0.47, 1.0, 1.0)
|
||||
materialNodes['Principled BSDF'].inputs['Base Color'].default_value = (1.0, 0.47, 1.0, 1.0);
|
||||
|
||||
# Calls the functions:
|
||||
cleanScene();
|
||||
spawnGround();
|
||||
|
||||
# Notes:
|
||||
# - For loop for the grid:
|
||||
|
Reference in New Issue
Block a user