from TSsupport import rand, randint
from math import *
import trueSpace

doc = trueSpace.GetActiveDocument()
doc.ClearOutTxt()

#
# Blank script
#


first = doc.CurrentSelection()



       


thickness = 2
progress = 0
for particle in range (1, thickness +1):
     

     numberobjectshmm = 15
     distanceup = 10
     xs = 0
     zs = 0
     ys = 0
     scales = 3
     scalesrandom = 10
     secound = doc.Object("Sphere")
     scalinglooph = rand()*15
     xsc = scales 
     zsc = scales 
     ysc = scales
     windx = 10
     windz = 0
     blowx = 30
     blowz = 0
     position= 0

     for particle in range (1, numberobjectshmm +1):
         doc.CurrobjCopy()
         secound = doc.CurrentSelection()
         xs = rand()*position + windx
         zs = rand()*position + windz
         randint = 200
         ys = ys + rand()*10 + distanceup 
         windx = windx + blowx + rand()*distanceup 
         windz = windz + blowz + rand()*distanceup 
         secound.Position = (xs,zs,ys)
         randint = scalesrandom
         scaling = doc.CurrentSelection()
         secound.Rotate("x", rand()*40)
         secound.Rotate("y", rand()*40)
         secound.Rotate("z", rand()*40)
         xsc = xsc + scalinglooph /2+ distanceup
         zsc = zsc + scalinglooph /2+ distanceup
         ysc = ysc + scalinglooph + rand()/2+distanceup
         scaling.Scale = (xsc,zsc,ysc)
         randint = distanceup
         position = position + numberobjectshmm     
         distanceup = distanceup +  distanceup / 3        
         


     



     

                    
    


     

# Group the Array
totalnew = + thickness *  numberobjectshmm +1
Objectsname = "Sphere"
for glueobject in range (1,totalnew): 
       next = doc.Object (Objectsname + "," + str(glueobject)) 
       group = doc.GroupAtCurrobj (next)
                                             
                

doc.Draw()
print "You made this many objects {"
print thickness * numberobjectshmm 
print "}"
trueSpace.Stop()


 


