Maya Particle Geometry Generator Script

#particles.py
  
import random
import os.path
import math
  
#----------------------------------------------------
def Dome(fullpath, num_particles, inner_rad, outer_rad):
    f = open(fullpath, 'w')
    f.write('particle\n')
    counter = 0
    #for n in range(num_particles):
    while counter < num_particles:
        x = random.uniform(-float(outer_rad), float(outer_rad))
        y = random.uniform(0, float(outer_rad))
        z = random.uniform(-float(outer_rad), float(outer_rad))
        dist = math.sqrt(x*x + y*y + z*z)
        if dist <= outer_rad and dist >= inner_rad:
            f.write('-p %1.3f %1.3f %1.3f \n' % (x,y,z) )
            counter += 1
    f.write(';\n')
    f.close()
  
homepath = os.path.expanduser('~')
filename = 'dome.mel'
fullpath = os.path.join(homepath, filename)
Dome(fullpath, 3000, 7.4, 7.5)