A.N.T.(Another Noise Tool)v.0.2 _Mixed Noise_

A new A.N.T. now with double noise function ,
so you can mix 2 different noises in many ways.

This script creates a distorted copy of the mesh you sellect.
U can use this tool for many purposes,like creating terrains,rocks,planets…and more.

note: YOU HAVE TO REMOVE ALL SPACES AFTER THE SLASHES \
AFTER YOU COPY AND PASTE THIS SCRIPT…sorry.


#!BPY

"""
Name: 'A.N.T.0.2'
Blender: 233
Group: 'Misc'
Tip: 'Another Noise Tool 0.2 ,Mixed noise.  Distort mesh with noise.'
"""

#################################################################################
# A.N.T.(Another Noise Tool) v.0.2 'Mixed noise'.
# Jimmy Hazevoet , juli 2004
#################################################################################
# Thank's to jmsoler,Tessalate8_8i.py,for 'Save'/'Load' file functionality.
# Official page for this fantastic 'Tessalate' script:
#   http://jmsoler.free.fr/didacticiel/blender/tutor/python_wireshadows.htm
#################################################################################

import Blender
from Blender import *
from Blender.Noise import *
from math import *
from Blender.Draw import *
from Blender.BGL import *

#---------------------------------------------------------------------
Pre_View = Create(0)
message = ""
#---------------------------------------------------------------------
dirpath=Blender.sys.dirname(Blender.Get('filename'))
print dirpath.replace('\\','/')+'/'
Terra_Path=dirpath.replace('\\','/')+'/'
#-------------------
class buttons:
   global Terra_Path
   def __init__(self):

# Mesh object #------------------------------------------------
      self.MEname = Create("Plane")      #= Get Mesh From Name.

# Save/Load as Filename #---------------------------------------
      self.Record={}
      self.Record['Save']=Create(0)
      self.Record['Load']=Create(0)
      self.Record['SaveAs']=Create('ANTBASICTest.ant') #='Filename'
      self.path=Terra_Path
      self.buttonslist=[]
# Toggle #-----------------------------------------------------
      self.N1_To = Create(1)       #= Toggle Noise 1
      self.Fi_To = Create(0)       #= Toggle Mixer/Filter
      self.N2_To = Create(0)       #= Toggle Noise 2

# Mixer #------------------------------------------------------
      self.PFunc = Create(1)      #= mix menu
      self.plev    =Create(10.0)  #= Plateau level
      self.slev    =Create(-10.0) #= Sea level
      self.iSca = Create(1.0)     #= Intensity scale1
      self.N2iSca = Create(1.0)   #= Intensity scale2
      self.sinus1  = Create(2.0)  #= a
      self.sinus2  = Create(2.0)  #= b
      self.Sci  = Create(4.0)     #= c
                                  #formula (from math import*)
                                  #(S1,S2,z, x,y,z, a,b,c, n1,n2)
      self.S1string  = Create("a * n1") #= S1 ,string 1
      self.S2string  = Create("b * n2") #= S2 ,string 2
      self.zstring   = Create("S1+S2")  #= z  ,string result
# Noise 1 #----------------------------------------------------
      self.NFunc = Create(1)      #= Noise function 1
      self.Sx = Create(1.0)       #= Scale X
      self.Sy = Create(1.0)       #= Scale Y
      self.Sz = Create(1.0)       #= Scale Z
      self.Lx = Create(0.0)       #= Loc. X
      self.Ly = Create(0.0)       #= Loc. Y
      self.Lz = Create(0.0)       #= Loc. Z
      self.NSize = Create(0.25)	  #= Noise size
      # self.iSca = Create(1.0)	  #= Intensity scale1
      self.NType = Create(1)      #= Musgrave noise
      self.BType = Create(1)      #= Basis noise
      self.Oc = Create(2.0)       #= Octaves
      self.La = Create(2.0)       #= Lacunarity
      self.Ga = Create(1.0)       #= Gain
      self.Ha = Create(1.0)       #= H
      self.Of = Create(1.0)       #= Offset
      self.BDist1 = Create(1)     #= Distortion noise
      self.DAmnt  = Create(1.0)	  #= Distortion Amount
      self.TDep  = Create(2)      #= Turbulence Depth
      self.TSH   = Create(0)      #= Soft/Hard
      self.Tamp  = Create(0.5)    #= Ampscale
      self.Tfrq  = Create(2.0)    #= Freqscale
# Noise 2 #------------------------------------------------------
      self.N2Func = Create(3)     #= Noise function 2
      self.N2Sx = Create(1.0)     #= Scale X
      self.N2Sy = Create(1.0)     #= Scale Y
      self.N2Sz = Create(1.0)     #= Scale Z
      self.N2Lx = Create(0.0)     #= Loc. X
      self.N2Ly = Create(0.0)     #= Loc. Y
      self.N2Lz = Create(0.0)     #= Loc. Z
      self.N2Size = Create(0.25)  #= Noise size
      # self.N2iSca = Create(1.0) #= Intensity scale2
      self.N2Type = Create(1)     #= Musgrave noise2
      self.N2BType = Create(1)    #= Basis noise2
      self.N2Oc = Create(2.0)     #= Octaves
      self.N2La = Create(2.0)     #= Lacunarity
      self.N2Ga = Create(1.0)     #= Gain
      self.N2Ha = Create(1.0)     #= H
      self.N2Of = Create(1.0)     #= Offset
      self.N2BDist1 = Create(1)   #= Distortion noise2
      self.N2DAmnt  = Create(1.0) #= Distortion Amount
      self.N2TDep  = Create(2)    #= Turbulence Depth
      self.N2TSH   = Create(0)    #= Soft/Hard
      self.N2Tamp  = Create(0.5)  #= Ampscale
      self.N2Tfrq  = Create(2.0)  #= Freqscale
# Save file#----------------------
   def prf_dump(self):
      global message
      n0=dir(self)
      f=open(self.path+self.Record['SaveAs'].val,'w')
      for n in n0:
         #print n0,
         if  (n.find('__')!=0 and n.find('prf_dump')==-1\
               and n.find('prf_load')==-1 and n.find('prf_save')==-1\
               and n.find('path')==-1) and n.find('Record')==-1:
            exec """l1=str(type(self.%s))"""%n
            l0=n+';'+l1+'
'
            f.write(l0)
            exec """f.write(str(self.%s))"""%n
            message = "  File Saved !"
            f.write('
')
      f.close()
# Load file#----------------------
   def prf_load(self):
      global message
      try:
         f=open(self.path+self.Record['SaveAs'].val,'r')
         buffer=f.readlines()
         f.close()
         for n in range(0,len(buffer),2):
            var=buffer[n].split(';')
            if var[0] not in self.buttonslist:
               self.buttonslist.append(var[0])
            if buffer[n].find("""<type 'str""")!=-1:
               exec """self.%s='''%s'''"""%(var[0],buffer[n+1][:-1])               
            elif buffer[n].find("""<type 'dict'>""")!=-1:
               exec """provdict=%s"""%buffer[n+1][:-1]
               for d in provdict.keys():
                  l00="""self.%s['%s'].val=%s"""%(var[0],d,provdict[d])
                  exec l00
            elif buffer[n].find("""<type 'Button'>""")!=-1:
                  exec """self.%s.val=%s"""%(var[0],buffer[n+1][:-1])
            message = " File Loaded !"
      except:
         message = "No such file !"
         print "File does not exist !"
B=buttons()

#-------------------------------------------------------------------------
def reset_N1():
   global B
   B.Sx = Create(1.0)
   B.Sy = Create(1.0)
   B.Sz = Create(1.0)
   B.Lx = Create(0.0)
   B.Ly = Create(0.0) 
   B.Lz = Create(0.0)
   B.NSize = Create(0.25)
   B.iSca = Create(1.0)
   B.DAmnt = Create(1.0)
   B.BDist1 = Create(1)
   B.NType = Create(1)
   B.BType = Create(1)
   B.Oc = Create(2.0)
   B.La = Create(2.0)
   B.Ga = Create(1.0)
   B.Ha = Create(1.0)
   B.Of = Create(1.0)
   B.TDep  = Create(2)
   B.TSH   = Create(0)
   B.Tamp  = Create(0.5)
   B.Tfrq  = Create(2.0)
#---------------------------
def reset_N2():
   global B
   B.N2Sx = Create(1.0)
   B.N2Sy = Create(1.0)
   B.N2Sz = Create(1.0)
   B.N2Lx = Create(0.0)
   B.N2Ly = Create(0.0) 
   B.N2Lz = Create(0.0)
   B.N2Size = Create(0.25)
   B.N2iSca = Create(1.0)
   B.N2DAmnt = Create(1.0)
   B.N2BDist1 = Create(1)
   B.N2Type = Create(1)
   B.N2BType = Create(1)
   B.N2Oc = Create(2.0)
   B.N2La = Create(2.0)
   B.N2Ga = Create(1.0)
   B.N2Ha = Create(1.0)
   B.N2Of = Create(1.0)
   B.N2TDep  = Create(2)
   B.N2TSH   = Create(0)
   B.N2Tamp  = Create(0.5)
   B.N2Tfrq  = Create(2.0)

#---------------------------
def reset_Mixer():
   global B
   #B.PFunc   = Create(1)
   B.iSca   = Create(1.0)
   B.N2iSca = Create(1.0)
   B.sinus1  = Create(1.0)
   B.sinus2  = Create(1.0)
   B.Sci    = Create(2.0)
   B.S1string  = Create("0")
   B.S2string  = Create("0")
   B.zstring  = Create("0")
   B.plev = Create(10.0)
   B.slev = Create(-10.0)


#-----------------------------------------------------------------------------
def Noise_func(x,y,z):
   global B

# n1 = Noise1-------------------------------------------
   x1 = (x / B.Sx.val + B.Lx.val) / B.NSize.val
   y1 = (y / B.Sy.val + B.Ly.val) / B.NSize.val
   z1 = (z / B.Sz.val + B.Lz.val) / B.NSize.val
   B0 = B.BType.val-1
   B1 = B.BDist1.val-1
   if B0 == 9: B0 = 14
   if B1 == 9: B1 = 14
   if (B.NFunc.val == 1):
      Ha1 = B.Ha.val
      La1 = B.La.val
      Oc1 = B.Oc.val
      Of1 = B.Of.val
      Ga1 = B.Ga.val
      if (B.NType.val == 1):
         no1 = multiFractal((x1,y1,z1),Ha1,La1,Oc1,B0)
      if (B.NType.val == 2):
         no1 = ridgedMFractal((x1,y1,z1),Ha1,La1,Oc1,Of1,Ga1,B0)
      if (B.NType.val == 3):
         no1 = hybridMFractal((x1,y1,z1),Ha1,La1,Oc1,Of1,Ga1,B0)
      if (B.NType.val == 4):
         no1 = heteroTerrain((x1,y1,z1),Ha1,La1,Oc1,Of1,B0)
      if (B.NType.val == 5):
         no1 = fBm((x1,y1,z1),Ha1,La1,Oc1,B0)
   if (B.NFunc.val == 2):
      no1 = vlNoise((x1,y1,z1),B.DAmnt.val,B1,B0)
   if (B.NFunc.val == 3):
      TD=B.TDep.val
      SH=B.TSH.val
      no1 = turbulence((x1,y1,z1),TD,SH,B0,B.Tamp.val,B.Tfrq.val)

   n1 = no1 * B.iSca.val/3

# n2 = Noise2-------------------------------------------
   x2 = (x / B.N2Sx.val + B.N2Lx.val) / B.N2Size.val
   y2 = (y / B.N2Sy.val + B.N2Ly.val) / B.N2Size.val
   z2 = (z / B.N2Sz.val + B.N2Lz.val) / B.N2Size.val
   N2B  = B.N2BType.val-1
   N2B1 = B.N2BDist1.val-1
   if N2B == 9: N2B =14
   if N2B1 == 9: N2B1 =14
   if (B.N2Func.val == 1):
      Ha2 = B.N2Ha.val
      La2 = B.N2La.val
      Oc2 = B.N2Oc.val
      Of2 = B.N2Of.val
      Ga2 = B.N2Ga.val
      if (B.N2Type.val == 1):
         no2 = multiFractal((x2,y2,z2),Ha2,La2,Oc2,N2B)
      if (B.N2Type.val == 2):
         no2 = ridgedMFractal((x2,y2,z2),Ha2,La2,Oc2,Of2,Ga2,N2B)
      if (B.N2Type.val == 3):
         no2 = hybridMFractal((x2,y2,z2),Ha2,La2,Oc2,Of2,Ga2,N2B)
      if (B.N2Type.val == 4):
         no2 = heteroTerrain((x2,y2,z2),Ha2,La2,Oc2,Of2,N2B)
      if (B.N2Type.val == 5):
         no2 = fBm((x2,y2,z2),Ha2,La2,Oc2,N2B)
   if (B.N2Func.val == 2):
      no2 = vlNoise((x2,y2,z2),B.N2DAmnt.val,N2B1,N2B)
   if (B.N2Func.val == 3):
      TD2=B.N2TDep.val
      SH2=B.N2TSH.val
      no2=turbulence((x2,y2,z2),TD2,SH2,N2B,B.N2Tamp.val,B.N2Tfrq.val)

   n2 = no2 * B.N2iSca.val/3

# Mix n1,n2-------------------------------------------
   if B.PFunc.val == 1:
      z = n1
   if B.PFunc.val == 2:
      z = n2
   if B.PFunc.val == 3:
      z = n1 + n2
   if B.PFunc.val == 4:
      z = n1 - n2
   if B.PFunc.val == 5:
      z = n1 * n2
   if B.PFunc.val == 6:
      z = n1 / n2
   if B.PFunc.val == 7:
      z = n1 > n2

   if B.PFunc.val > 7:
      a=B.sinus1.val
      b=B.sinus2.val
      c=B.Sci.val
   if B.PFunc.val == 8:
      z = sin(c*y-y/2+a)*n1 + cos(c*y-y/2+b)*n2
   if B.PFunc.val == 9:
      sq = c*sqrt((x-x/2)**2+(y-y/2)**2)
      z  = sin(a*sq)*n1 + cos(b*sq)*n2
   if B.PFunc.val == 10:
      sq = 4*sqrt((x-x/2)**2+(y-y/2)**2)
      spi = x*sin(a*2*sq)+n1 + y*cos(b*2*sq)+n2
      z = z+0.25*spi*c
   if B.PFunc.val == 11:
      S1func = B.S1string.val
      S2func = B.S2string.val
      zfunc = B.zstring.val
      S1 = eval(S1func)
      S2 = eval(S2func)
      z = eval(zfunc)

   return x,y,z


# Mesh function ----------------------------------------------------------------
def func():
   global B, message
   try:
      obj = Blender.Object.GetSelected()
      if obj !=[] and len(obj) == 1:
         obj = obj[0]
         m = Blender.NMesh.GetRawFromObject(obj.name)
      else:
         m = NMesh.GetRawFromObject(B.MEname.val)
   except:
      print 'No selected object.  Please select a Mesh'
      message = "Sellect a Mesh !"
      return 0
   COMpute()

   #--------------------------
   normals = []
   coordinates = []
   for v in m.verts:
      i = m.verts.index(v)
      normals.append([v.no[0],v.no[1],v.no[2]])
      coordinates.append([v.co[0],v.co[1],v.co[2]])
      NOISE1F = Noise_func(v.co[0],v.co[1],v.co[2])
      mvg_result = NOISE1F[2]
      if (mvg_result < B.slev.val): mvg_result = B.slev.val
      if (mvg_result > B.plev.val): mvg_result = B.plev.val
      for z in range(3): 
         v.co[z] = coordinates[i][z] + (mvg_result * normals[i][z])

   Blender.NMesh.PutRaw(m)
   message = "Mesh created."


# Preview ----------------------------------------------------------------------
def PreviewNoise():
   for x in range(-50, 50):
      for y in range(-50, 50):
         z=0.0
         poco = Noise_func(x/50.0, y/50.0, z/50.0)
         pointCol = poco[2]
         r = (pointCol+1.0)/2.0
         g = (pointCol+1.0)/2.0
         b = (pointCol+1.0)/2.0
         glColor3f(r,g,b)
         glRecti(x+160, y+380, x+161, y+381)
# G.U.I.------------------------------------------------------------------------
def gui():
   global B, Pre_View
   BGL.glClearColor(0.6, 0.6, 0.6, 1)
   BGL.glClear(BGL.GL_COLOR_BUFFER_BIT)
   glColor3f(0.35,0.45,0.55)
   glRecti(5, 5, 315, 480)
   glColor3f(1.0,1.0,1.0)
   glRasterPos2d(120, 465)
   Text(message)

   if Pre_View.val == 1:
      PreviewNoise()
      Pre_View = Toggle("Preview", 3,30,355,50,50, Pre_View.val)
   else:
      Pre_View = Toggle("Preview", 3,110,330,100,100, Pre_View.val)

   SLt="Name of file to Save or Load"
   BRSA=B.Record['SaveAs'].val
   B.Record['SaveAs']=String("file: ",3,10,435,300,20,BRSA,256,SLt)
   B.Record['Save']=Button("Save", 9, 10, 460, 100, 15)
   B.Record['Load']=Button("Load", 10, 210, 460, 100, 15)

   metxt="GetRawFromObject(name)   :   "
   B.MEname = String(metxt,3,10,45,300,20,B.MEname.val,200)

   B.N1_To = Toggle("n1",31,10,305,100,20, B.N1_To.val)
   B.Fi_To = Toggle("Mix",33,110,305,100,20, B.Fi_To.val)
   B.N2_To = Toggle("n2",32,210,305,100,20, B.N2_To.val)
   #---------------------------------------------------------------------------
   if B.Fi_To.val == 1:
      Button("Reset Mi", 6, 250,335,60,15)

      Pf = "Mix type's%t|n1 %x1|n2 %x2|n1 + n2 %x3|n1 - n2%x4|n1 * n2%x5\
            |n1 / n2%x6|n1 > n2%x7|sinus1%x8|sinus2%x9|sinus3%x10|formula%x11"
      B.PFunc = Menu(Pf, 3, 110,130,100,20, B.PFunc.val)
      if B.PFunc.val == 1:
         B.iSca=Number("iScale n1: ",3,10,105,145,20,B.iSca.val,-10.0,10.0)
         B.NSize=Number("n1Size: ",3,10,130,90,20,B.NSize.val,0.001,20.0)
      if B.PFunc.val == 2:
         B.N2iSca=Number("iScale n2: ",3,165,105,145,20,B.N2iSca.val,-10.0,10.0)
         B.N2Size=Number("n2Size: ",3,220,130,90,20,B.N2Size.val,0.001,20.0)
      if B.PFunc.val > 2:
         B.iSca=Number("iScale n1: ",3,10,105,145,20,B.iSca.val,-10.0,10.0)
         B.NSize=Number("n1Size: ",3,10,130,90,20,B.NSize.val,0.001,20.0)
         B.N2iSca=Number("iScale n2: ",3,165,105,145,20,B.N2iSca.val,-10.0,10.0)
         B.N2Size=Number("n2Size: ",3,220,130,90,20,B.N2Size.val,0.001,20.0)
      if B.PFunc.val > 7:
         B.sinus1=Number("a : ",3,10,160,100,20,B.sinus1.val,-10.0,10.0)
         B.sinus2=Number("b : ",3,210,160,100,20,B.sinus2.val,-10.0,10.0)
         B.Sci = Number("c : ",3,120,160,80,20,B.Sci.val,-10.0,10.0)
      if B.PFunc.val > 10:
         B.S1string=String("S1 : ",303,10,235,300,20,B.S1string.val,250,"Input S1")
         B.S2string=String("S2 : ",303,10,210,300,20,B.S2string.val,250,"Input S2")
         B.zstring=String("z : ",303,10,185,300,20,B.zstring.val,250,"Output")

      B.slev=Number("Min.:",3,10,80,150,15,B.slev.val,-50.0,50.0,"Sealevel")
      B.plev=Number("Max.:",3,160,80,150,15,B.plev.val,-50.0,50.0,"Plateau")

   #---------------------------------------------------------------------------
   if B.N1_To.val == 1:
      Button("Reset n1", 4, 250,335,60,15)

      B.iSca = Number("iScale : ", 3,10,145,150,25,B.iSca.val,-10.0,10.0)
      B.NSize=Number("NoiseSize : ",3,160,145,150,25,B.NSize.val,0.001,20.0)
      B.Sx = Number("sizeX : ", 3, 160,115,150,20, B.Sx.val,0.0,10.0)
      B.Sy = Number("sizeY : ", 3, 160,95,150,20, B.Sy.val,0.0,10.0)
      B.Sz = Number("sizeZ : ", 3, 160,75,150,20, B.Sz.val,0.0,10.0)
      B.Lx = Number("ofsX : ", 3, 10,115,150,20, B.Lx.val,-1000.0,1000.0)
      B.Ly = Number("ofsY : ", 3, 10,95,150,20, B.Ly.val,-1000.0,1000.0)
      B.Lz = Number("ofsZ : ", 3, 10,75,150,20, B.Lz.val,-1000.0,1000.0)

      Nn="Noise 1 Type's%t|Musgrave 1%x1|DistortedNoise 1%x2|Turbulence 1%x3"
      B.NFunc = Menu(Nn, 3, 10,275,300,25, B.NFunc.val)
      if (B.NFunc.val == 1):
         Bn = "Noise Basis%t|Blender Original%x1|Original Perlin%x2\
               |Improved Perlin%x3|Voronoi_F1%x4|Voronoi_F2%x5\
               |Voronoi_F3%x6|Voronoi_F4%x7|Voronoi_F2-F1%x8\
               |Voronoi Crackle%x9|CellNoise%x10"
         B.BType = Menu(Bn, 3, 160,175,150,20, B.BType.val)
         Fn = "Musgrave Type's%t|MultiFractal%x1|RidgedMF%x2\
               |HybridMF%x3|HTerrain%x4|fBm%x5"
         B.NType = Menu(Fn, 3, 10,175,150,20, B.NType.val)
         B.Oc = Slider("Octs : ", 3, 10,205,150,20, B.Oc.val,0.0,8.0 ,0)
         B.La = Slider("Lacu : ", 3, 160,205,150,20, B.La.val,0.0,6.0 ,0)
         B.Ha = Slider("H : ", 3, 10,225,150,20, B.Ha.val,0.0,2.0 ,0)
         if (B.NType.val == 2):
            B.Of = Slider("Ofst : ",3,160,225,150,20,B.Of.val,0.0,6.0,0)
            B.Ga = Slider("Gain : ",3,10,245,150,20,B.Ga.val,0.0,6.0,0)
         if (B.NType.val == 3):
            B.Of = Slider("Ofst : ",3,160,225,150,20,B.Of.val,0.0,6.0,0)
            B.Ga = Slider("Gain : ",3,10,245,150,20,B.Ga.val,0.0,6.0,0)
         if (B.NType.val == 4):
            B.Of = Slider("Ofst : ",3,160,225,150,20,B.Of.val,0.0,6.0,0)

      if (B.NFunc.val == 2):
         Bn="Noise Basis%t|Blender Original%x1|Original Perlin%x2\
               |Improved Perlin%x3|Voronoi_F1%x4|Voronoi_F2%x5\
               |Voronoi_F3%x6|Voronoi_F4%x7|Voronoi_F2-F1%x8\
               |Voronoi Crackle%x9|CellNoise%x10"
         B.BType = Menu(Bn, 3, 160,175,150,20, B.BType.val)
         Bd1="Distortion Noise%t|Blender Original%x1|Original Perlin%x2\
               |Improved Perlin%x3|Voronoi_F1%x4|Voronoi_F2%x5\
               |Voronoi_F3%x6|Voronoi_F4%x7|Voronoi_F2-F1%x8\
               |Voronoi Crackle%x9|CellNoise%x10"
         B.BDist1 = Menu(Bd1, 3, 10,175,150,20, B.BDist1.val)
         damnt="Distortion Amount : "
         B.DAmnt = Slider(damnt,3,10,205,300,20,B.DAmnt.val,0.0,10.0, 0)

      if (B.NFunc.val == 3):
         Bn = "Noise Basis%t|Blender Original%x1|Original Perlin%x2\
            |Improved Perlin%x3|Voronoi_F1%x4|Voronoi_F2%x5\
            |Voronoi_F3%x6|Voronoi_F4%x7|Voronoi_F2-F1%x8\
            |Voronoi Crackle%x9|CellNoise%x10"
         B.BType = Menu(Bn, 3, 160,175,150,20, B.BType.val)
         B.TDep = Number("Depth : ",3,10,175,100,20,B.TDep.val,0.0,10.0)
         B.TSH = Toggle("S/H", 3, 110,175,50,20,B.TSH.val)
         B.Tamp = Number("Amp. : ",3,10,205,150,20,B.Tamp.val,0.0,10.0)
         B.Tfrq = Number("Freq. : ",3,160,205,150,20,B.Tfrq.val,0.0,10.0)

   #---------------------------------------------------------------------------
   if B.N2_To.val == 1:
      Button("Reset n2", 5, 250,335,60,15)

      B.N2iSca = Number("iScale : ",3,10,145,150,25,B.N2iSca.val,-10.0,10.0)
      B.N2Size=Number("NoiseSize : ",3,160,145,150,25,B.N2Size.val,0.001,20.0)
      B.N2Sx = Number("sizeX : ",3,160,115,150,20, B.N2Sx.val,0.0,10.0)
      B.N2Sy = Number("sizeY : ",3,160,95,150,20, B.N2Sy.val,0.0,10.0)
      B.N2Sz = Number("sizeZ : ",3,160,75,150,20, B.N2Sz.val,0.0,10.0)
      B.N2Lx = Number("ofsX : ",3,10,115,150,20, B.N2Lx.val,-1000.0,1000.0)
      B.N2Ly = Number("ofsY : ",3,10,95,150,20, B.N2Ly.val,-1000.0,1000.0)
      B.N2Lz = Number("ofsZ : ",3,10,75,150,20, B.N2Lz.val,-1000.0,1000.0)

      Nn2="Noise 2 Type's%t|Musgrave 2%x1|DistortedNoise 2%x2|Turbulence 2%x3"
      B.N2Func = Menu(Nn2, 3, 10,275,300,25, B.N2Func.val)
      if (B.N2Func.val == 1):
         Bn2="Noise Basis%t|Blender Original%x1|Original Perlin%x2\
               |Improved Perlin%x3|Voronoi_F1%x4|Voronoi_F2%x5\
               |Voronoi_F3%x6|Voronoi_F4%x7|Voronoi_F2-F1%x8\
               |Voronoi Crackle%x9|CellNoise%x10"
         B.N2BType=Menu(Bn2, 3, 160,175,150,20, B.N2BType.val)
         Fn2="Musgrave Type's%t|MultiFractal%x1|RidgedMF%x2\
               |HybridMF%x3|HTerrain%x4|fBm%x5"
         B.N2Type = Menu(Fn2, 3,10,175,150,20,B.N2Type.val)
         B.N2Oc = Slider("Octs : ",3,10,205,150,20,B.N2Oc.val,0.0,8.0,0)
         B.N2La = Slider("Lacu : ",3,160,205,150,20,B.N2La.val,0.0,6.0,0)
         B.N2Ha = Slider("H : ",3,10,225,150,20,B.N2Ha.val,0.0,2.0,0)
         if (B.N2Type.val == 2):
            B.N2Of = Slider("Ofst : ",3,160,225,150,20,B.N2Of.val,0.0,6.0,0)
            B.N2Ga = Slider("Gain : ",3,10,245,150,20,B.N2Ga.val,0.0,6.0,0)
         if (B.N2Type.val == 3):
            B.N2Of = Slider("Ofst : ",3,160,225,150,20,B.N2Of.val,0.0,6.0,0)
            B.N2Ga = Slider("Gain : ",3,10,245,150,20,B.N2Ga.val,0.0,6.0,0)
         if (B.N2Type.val == 4):
            B.N2Of = Slider("Ofst : ",3,160,225,150,20,B.N2Of.val,0.0,6.0,0)

      if (B.N2Func.val == 2):
         Bn2="Noise Basis%t|Blender Original%x1|Original Perlin%x2\
               |Improved Perlin%x3|Voronoi_F1%x4|Voronoi_F2%x5\
               |Voronoi_F3%x6|Voronoi_F4%x7|Voronoi_F2-F1%x8\
               |Voronoi Crackle%x9|CellNoise%x10"
         B.N2BType=Menu(Bn2, 3, 160,175,150,20, B.N2BType.val)
         Bd12="Distortion Noise%t|Blender Original%x1|Original Perlin%x2\
               |Improved Perlin%x3|Voronoi_F1%x4|Voronoi_F2%x5\
               |Voronoi_F3%x6|Voronoi_F4%x7|Voronoi_F2-F1%x8\
               |Voronoi Crackle%x9|CellNoise%x10"
         B.N2BDist1=Menu(Bd12, 3,10,175,150,20,B.N2BDist1.val)
         damnt2="Distortion Amount : "
         B.N2DAmnt=Slider(damnt2,3,10,205,300,20,B.N2DAmnt.val,0.0,10.0,0)

      if (B.N2Func.val == 3):
         Bn2="Noise Basis%t|Blender Original%x1|Original Perlin%x2\
               |Improved Perlin%x3|Voronoi_F1%x4|Voronoi_F2%x5\
               |Voronoi_F3%x6|Voronoi_F4%x7|Voronoi_F2-F1%x8\
               |Voronoi Crackle%x9|CellNoise%x10"
         B.N2BType=Menu(Bn2, 3,160,175,150,20, B.N2BType.val)
         B.N2TDep=Number("Depth : ",3,10,175,100,20,B.N2TDep.val,0.0,10.0)
         B.N2TSH=Toggle("S/H",3,110,175,50,20, B.N2TSH.val)
         B.N2Tamp=Number("Amp. : ",3,10,205,150,20,B.N2Tamp.val,0.0,10.0)
         B.N2Tfrq=Number("Freq. : ",3,160,205,150,20,B.N2Tfrq.val,0.0,10.0)

   Button("Create", 2, 10,10,300,30," Create ( Space key ) ")
   Button("Exit", 1, 250,400,60,20," Exit ( Esc. key ) ")

#---------------------------------------
def COMpute():
   global message
   message = "Compute."
   Draw()
#---------------------------------------
def event(evt, val):
   global message
   if (evt == ESCKEY and not val):
      name = "OK?%t|Exit %x1"
      result = Blender.Draw.PupMenu(name)
      if result == 1:
         Exit()
   if (evt== SPACEKEY and not val):
      message = ""
      func()
      Blender.Redraw()
#---------------------------------------
def bevent(evt):
   global B, message

   if evt == 1:
      name = "OK?%t|Exit %x1"
      result = Blender.Draw.PupMenu(name)
      if result == 1:
         Exit()
   if evt == 2:
      func()
      Blender.Redraw()
   if evt == 3:
      message = ""
      Draw()
   if evt == 4:
      message = ""
      name = "OK?%t|Reset Noise 1 %x1"
      result = Blender.Draw.PupMenu(name)
      if result == 1:
         reset_N1()
         Draw()
   if evt == 5:
      message = ""
      name = "OK?%t|Reset Noise 2 %x1"
      result = Blender.Draw.PupMenu(name)
      if result == 1:
         reset_N2()
         Draw()
   if evt == 6:
      message = ""
      name = "OK?%t|Reset Mixer %x1"
      result = Blender.Draw.PupMenu(name)
      if result == 1:
         reset_Mixer()
         Draw()
   elif (evt == 31):
      message = ""
      if B.N1_To.val == 1:
         B.Fi_To.val = 0
         B.N2_To.val = 0
         Draw()
   elif (evt == 32):
      message = ""
      if B.N2_To.val == 1:
         B.N1_To.val = 0
         B.Fi_To.val = 0
         Draw()
   elif (evt == 33):
      message = ""
      if B.Fi_To.val == 1:
         B.N1_To.val = 0
         B.N2_To.val = 0
         Draw()
   elif (evt==9):
      message = ""
      name = "OK?%t|Save %x1"
      result = Blender.Draw.PupMenu(name)
      if result == 1:
         B.prf_dump()
         Blender.Window.Redraw()
   elif (evt==10):
      message = ""
      name = "OK?%t|Load %x1"
      result = Blender.Draw.PupMenu(name)
      if result == 1:
         B.prf_load()
         Blender.Window.Redraw()

Register(gui, event, bevent)

:smiley: :smiley: Thank you! Very useful!

I uploaded the Fixed Script(right click, save target as), so you don’t need to remove the spaces.

R2Blend:

Thank You! :smiley:

You’re welcome! It was easy.

some freeware apps to help with stripping and converting endings:

http://www.liquidninja.com/metapad/

http://www.pspad.com/

and to some extent

http://www.scintilla.org/SciTE.html

:smiley: Thank’s for the fix! :smiley: