import c4d
from c4d import storage
def main():
filepath = storage.LoadDialog(title = 'Select Gimp Gradient File', flags = c4d.FILESELECT_LOAD)
result = c4d.BaseList2D(c4d.Onull)
isstart = True
gradient = None
with open(filepath, 'r') as f:
gradient = c4d.Gradient()
for line in f:
print line
ldata = line.strip().split(' ')
if len(ldata) > 10:
p0 = float(ldata[0])
bias = float(ldata[1])
p1 = float(ldata[2])
c0 = c4d.Vector(float(ldata[3]), float(ldata[4]), float(ldata[5]))
b0 = float(ldata[6])
c1 = c4d.Vector(float(ldata[7]), float(ldata[8]), float(ldata[9]))
b1 = float(ldata[10])
if isstart:
gradient.InsertKnot(c0, b0, p0, bias)
isstart = False
gradient.InsertKnot(c1, b1, p1, bias)
if gradient is not None:
bc = c4d.GetCustomDataTypeDefault(1000481)
descid = result.AddUserData(bc)
result[descid] = gradient
doc.InsertObject(result)
c4d.EventAdd()
if __name__=='__main__':
main()