where do i tweak/insert this modification

hey there…complete noob here, so bear with me.

ok, so this is what i have from one of the tutorials:

 
import Blender
from Blender import NMesh

import math
from math import *

me=NMesh.GetRaw()

i=0.0
j=0.0

maxpoint=32.0*32.0

n=sqrt(maxpoint)
print n

for i in range(0,n):
    print i
    for j in range(0,n):
        print j
        x=sin(j*pi*2/(n-1))*cos(-pi/2+i*pi/(n-1))*2
        y=cos(j*pi*2/(n-1))*(1-cos(-pi/2+i*pi/(n-1)))*2
        z=sin(-pi/2+i*pi/(n-1))*2
        v=NMesh.Vert(x,y,z)
        me.verts.append(v)

n0=len(range(0,n))
print n0

for i in range(0,n-1):  
    for j in range(0,n-1):  
        f=NMesh.Face()  
        f.v.append(me.verts[i*n0+j])  
        f.v.append(me.verts[i*n0+j+1])  
        f.v.append(me.verts[(i+1)*n0+j+1])  
        f.v.append(me.verts[(i+1)*n0+j]) 
        me.faces.append(f) 
       
NMesh.PutRaw(me,"plane",1)  
Blender.Redraw()

now, i want to make it into a sphere, but what and where should i tweak it so that i can plug this in instead:


for i in range(0, n): 
       for j in range(0, n): 
        x = sin(j*pi*2/(n-1))*cos(-pi/2+i*pi/(n-1))*radius 
        y = cos(j*pi*2/(n-1))*cos(-pi/2+i*pi/(n-1))*radius 
        z = sin(-pi/2+i*pi/(n-1))*radius 
       v=NMesh.Vert( x , y , z ) 
       me.verts.append(v)  

do i also need to add anything else??

anyway, thanks for helping this noob!!

from Blender import NMesh
# Quelques fonctions du module mathematiques de  Python
# peuvent se reveler utiles,  le python, grand econome,
# ne charge que le strict minimum lorsqu'il est sollicite
# il est necessaire de demander le reste...
import math
from math import *
# Creation du reseau de polygones
me=NMesh.GetRaw()
#  Les strictes conditions du didacticiel
# on range la valeur 9 dans une variable maxpoint
maxpoint=32.0*32.0
# On applique systematiquement:
# on tire la racine carre de maxpoint avec 
# la fonction sqrt()
n=int(sqrt(maxpoint))
print n
r=2.0
for i in range(0,n):
    # Ici commence le premier sous-programme
    # quatre espaces d'indentation
    print i
    for j in range(0,n):
        # Ici commence la seconde boucle
        # huit espaces d'indentation                
        y=sin(j*pi/n*2.0)*cos(i*pi/n*2.0)*r
        x=cos(j*pi/n*2.0)*cos(i*pi/n*2.0)*r
        z=sin(pi/n*i*2.0)*r
        v=NMesh.Vert(x,y,z)
        me.verts.append(v)
        # Fin de la boucle interne
    #Fin de la boucle externe
#valeur entiere de n
n0=len(range(0,n))
print n0
for i in range(0,n-1):  
    # Ici commence le premier sous-programme  
    # quatre espaces d'indentation  
    for j in range(0,n-1):  
        # Ici commence la seconde boucle  
        # huit espaces d'indentation  
        f=NMesh.Face()  
        f.v.append(me.verts[i*n0+j])  
        f.v.append(me.verts[i*n0+j+1])  
        f.v.append(me.verts[(i+1)*n0+j+1])  
        f.v.append(me.verts[(i+1)*n0+j]) 
        # Apres avoir complete a facette 
        # on l'ajoute à la liste de "me" 
        me.faces.append(f) 
        # Fin de la boucle interne  
    #Fin de la boucle externe  
NMesh.PutRaw(me,"plane",1)  
Blender.Redraw()

The original text from this address:
http://jmsoler.free.fr/didacticiel/blender/tutor/english/python_script05.htm

thanks jms. script looks familiar doesn’t it? :smiley: except that’s what i already have, and it doesn’t give you a sphere. it’s just what you called a potatoid.

what do i have to do to make it a sphere?