Having trouble running code on Blender. What this code is supposed to do is make a sphere of cubes. It can make a circle just fine but is having troubles with the embedded while loop. It runs through the inner loop fine and makes a circle (of radius 0), but does not go through the "phi" while loop to make a sphere.
import bpy
from bpy import context
from math import sin, cos, radians
cubeobject = bpy.ops.mesh.primitive_cube_add
#get the cursor location in the scene
cursor = context.scene.cursor_location
#increase the radial distance of cubes in loop
RadDist = 5.0
#initialize some variables
xsize = 1.0
ysize = 1.0
zsize = 1.0
phi = 0
theta = 0.0
RadStep = 6.28/8.0
while phi < 3.14:
while theta < 6.28:
x = cursor.x + RadDist*cos(theta)*sin(phi+3.14/2)
y = cursor.y + RadDist*sin(theta)*sin(phi+(3.14/2))
z = cursor.z + RadDist*cos(phi)
cubeobject(location = (x,y,z))
#add cubes along the radial
theta += RadStep
#add cubes along the azimuthal
phi += RadStep
theta = 0.0
phi = 0.0