Adding entries to colorbands

I’m trying to write a script to manipulate colorbands, but I haven’t been able to figure out how to add entries to them.



Name: ‘Blend Interpolate’
Blender: 248
Group: ‘Misc’
Tooltip: ‘Creates a color in a colorband’
import BPyMesh
import Blender
import BPyMessages
import bpy

from Blender import Scene, Mesh, Window, sys, Texture, Material

def main():

sce =

 t = sys.time()

is_editmode = Window.EditMode()

tex1 = Blender.Texture.Get('Test')

if not tex1:
    tex1 = Blender.Texture.New('Test')


tex1.colorband.append( [.1,.1,.1,1,.5] )

print 'Interpolation finished in %.2f seconds' % (sys.time()-t)
if is_editmode: Window.EditMode(1)


the texture is created, but the colorband only contains the default entries.

It could be because you are passing an integer for your alpha value. Doesn’t and RGBA have to be all floats?


Okay, I tried that and it doesn’t seem to help.

Looks like you are right, the append is failing.

If you print the contents of the color band, you get the default values.

def main():
 sce =
 tex1 = Blender.Texture.Get('Test') #Assume Test already exists.
 myColorBand = tex1.colorband
 print myColorBand
 tex1.colorband.append( [0.1,0.1,0.1,1.0,.5] )

I figured it out

tex1 = Blender.Texture.Get(‘Test’)
colBand = tex1.colorband
tex1.colorband = colBand

Thanks for your help.

Cool, you have to re-assign the colorband after you append to it.