[Bf-python] new to blender

toy toy at toy.homeunix.net
Tue Aug 12 05:31:19 CEST 2003


Hi I am new to blender and I am starting to explore the python 
possibilites.  I have 2.28 and am reading the "blender book".  I am 
having problems getting a script from the book running.  Here it is:

import Blender

from Blender import NMesh, Object
from Blender.NMesh import Col
from math import sin,cos,sqrt,exp

xw=0.5
yw=0.5
xmax=36
ymax=36

me2 = NMesh.GetRaw()

for y in range(0,ymax):
         for x in range(0,xmax-1):
                 r=sqrt((x-xmax/2)**2+(y-ymax/2)**2)
                 z=sin(r*xw)*cos(r*yw)*exp(-r/5)*10
                 v=Nmesh.Vert(x,y,z)
                 me2.verts.append(v)

for y in range(0,ymax-1):
         for x in range(0,xmaxa-1):
                 a=x+y*ymax
                 f=Nmesh.Face()
                 f.v.append(me2.verts[a])
                 f.v.append(me2.verts[a+ymax])
                 f.v.append(me2.verts[a+ymax+1])
                 f.v.append(me2.verts[a+1])
                 me2.faces.append(f)

NMesh.PutRaw(me2,"Function",1)
Blender.Redraw()

I would appreciate it if you could help me.  The error that the script 
stops on isthe 4th line, the math import line:
from math import sin,cos,sqrt,exp
I tried to test as much as I could myself(I don't code in pytohn too 
much) and I guess the math modules aren't included? Thanks for any tips 
or pointers you guys will give.




More information about the Bf-python mailing list