#!BPY

"""
Name: 'CG-Light Exporter'
Blender: 245
Group: 'Export'
Tooltip: 'Exports the light attributes'
"""
import Blender
import bpy
import BPyMessages

def write(filename):
    if not BPyMessages.Warning_SaveOver(filename):
        return
    out = file(filename, "w")
    for ob in bpy.data.objects:
      if (type(ob.getData())) == Blender.Types.LampType:        
        position = ob.getLocation()
        rotation = ob.getMatrix()
        color = ob.getData().col
        out.write(ob.name + "\n")
        out.write(str(position[0]) + "\n")
        out.write(str(position[1]) + "\n")
        out.write(str(position[2]) + "\n")
        out.write(str(rotation[2][0]) + "\n")
        out.write(str(rotation[2][1]) + "\n")
        out.write(str(rotation[2][2]) + "\n")
        out.write(str(color[0]) + "\n")
        out.write(str(color[1]) + "\n")
        out.write(str(color[2]) + "\n")
        out.write(str(ob.getData().energy) + "\n")
    out.write("# Camera description file\n"+"# Written by Nikolai Knopp\n"+
      "# From top to bottom, the lines contain name,X Y Z Coordinates,\n"+
      "# then third row of Transformation Matrix, R G B color values, intensity.");

Blender.Window.FileSelector(write, "Export", Blender.sys.makename(ext='.lgt'))


