Help generating growth algorithm from multiple points

Hi, I am new to python (started last month for class). I am unsure of how to combine my scripts together. I am trying to reproduce a growth algorithm from the points generated from my divided surface, but I am not sure how to use a for loop to implement multiple points into the next step.

To explain further:


^ I want to grow these spheres


^ Out of each point I generated here


^Those points came from this surface I made

I am just unsure how to combine it together without it giving me an error. I got it to work with one point, just not multiple.

This is the script I have so far:

“”"
How to generate growth from the points of a surface
“”"

import rhinoscriptsyntax as rs
import random

#-------------------------------------------------

#Selects the already created base surface from rhino

BASE = rs.GetObject(“Pick any object”)

if BASE:
print "Object identifier: ", BASE

#-------------------------------------------------

#Determines the number of divisions on the base surface

number_divisions = 15

def DivideSurface(BASE, divisions):
u_domain = rs.SurfaceDomain(BASE, 0) #Gets the original u-direction domain of the base surface
v_domain = rs.SurfaceDomain(BASE, 1) #Gets the original v-direction domain of the base surface
for i in range(divisions+1):
u = u_domain[0] + (u_domain[1]-u_domain[0])*i/divisions #Divides the original u-direction domain of the base surface
for j in range(divisions+1):
v = v_domain[0] + (v_domain[1]-v_domain[0])*j/divisions #Divides the original v-direction domain of the base surface
point = rs.EvaluateSurface(BASE,u,v)
rs.AddPoint(point) #Adds the points generated from the divisions onto the base surface
rs.AddSphere(point, 2) #Adds spheres onto the points

DivideSurface(BASE, number_divisions) ##Generates points based on the number of divisions and adds spheres onto the points

#-------------------------------------------------

rs.DeleteObject(BASE)

#-------------------------------------------------

from Rhino import *
from Rhino.DocObjects import *
from Rhino.Commands import *
from Rhino.Input import *
from Rhino.Input.Custom import *
from scriptcontext import doc

#selects multiple points that already exists
#using the RhinoScript syntax
point_ids = rs.GetObjects(“Select point”, rs.filter.point)
for p_id in point_ids:
print “point id: {0}”.format(p_id)

#-------------------------------------------------

#Simple Growth script

import random #This module implements pseudo-random number generators for various distributions

def placePt(x_range,y_range,z_range):
x = random.uniform(0,x_range) #Random uniform gets a random number in the range specified
y = random.uniform(0,y_range)
z = random.uniform(0,z_range)
pt = [x,y,z] #Creates a point based on the random uniform generator
return pt

rs.EnableRedraw(False)

ptZero = [50,50,50] #Starting point where growth generates from
pts = #EmptyList
pts.append(ptZero) #Adds point zero to the list
sphereZero = rs.AddSphere(ptZero, .5) #Adds a sphere to the starting point

for i in range(0,1000): #Integers within given start and stop number
pt = rs.AddPoint(placePt(100,100,100)) #Runs the point into a randomizer through the range specified and adds it into rhino with the new coordinates
index = rs.PointArrayClosestPoint(pts,pt) #Point array finds the closest point to the set of points and will be used to create a vector
cp = pts[index]
vect = rs.VectorCreate(cp,pt) #Creates a vector from the closest point to the starting point
unitVect = rs.VectorUnitize(vect) #Unitize vector keeps the same direction but changes the length to 1 unit
subVect = vect - unitVect #Subtracts the original vector length with the new vector length to get a shorter vector
newPt = rs.MoveObject(pt,subVect) #Uses the subtracted vector result to move point and create a new point
rs.AddSphere(newPt,.5) #Adds a sphere to the newly created point
pts.append(newPt) #Adds new point to the list

rs.Redraw()