Skip to main content
added 42 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

Of the three choices my bet is that you're doing it wrong in that your o object is the lamp object, not the data part, or some other non LAMP data object.

import bpy
context = bpy.context
#o = bpy.data.objects.get("Lamp") # assumes you have an ob named Lamp
#o.data = bpy.data.lamps.get("Lamp")
o = context.active_object
if o:
    #o.energy 
    print("%s (%s)" % (o.name, o.type), getattr(o, "energy", "Has NO energy property"))
    o = o.data
    #o.data.energy
    if o:
        print("%s (%s)" % (o.name, o.type), getattr(o, "energy",  "Has NO energy property"))

If you grab a datapath from the DATA Properties panel, eg mesh panel for mesh objects, the datapath will be resolvable on the data part. context.active_object.data (except for empties, whose data part is None)

Of the three choices my bet is that you're doing it wrong in that your o object is the lamp object, not the data part, or some other non LAMP data object.

import bpy
context = bpy.context
#o = bpy.data.objects.get("Lamp") # assumes you have an ob named Lamp
o = context.active_object
if o:
    #o.energy 
    print("%s (%s)" % (o.name, o.type), getattr(o, "energy", "Has NO energy property"))
    o = o.data
    #o.data.energy
    if o:
        print("%s (%s)" % (o.name, o.type), getattr(o, "energy",  "Has NO energy property"))

If you grab a datapath from the DATA Properties panel, eg mesh panel for mesh objects, the datapath will be resolvable on the data part. context.active_object.data (except for empties, whose data part is None)

Of the three choices my bet is that you're doing it wrong in that your o object is the lamp object, not the data part, or some other non LAMP data object.

import bpy
context = bpy.context
#o = bpy.data.objects.get("Lamp") # assumes you have an ob named Lamp
#o.data = bpy.data.lamps.get("Lamp")
o = context.active_object
if o:
    #o.energy 
    print("%s (%s)" % (o.name, o.type), getattr(o, "energy", "Has NO energy property"))
    o = o.data
    #o.data.energy
    if o:
        print("%s (%s)" % (o.name, o.type), getattr(o, "energy",  "Has NO energy property"))

If you grab a datapath from the DATA Properties panel, eg mesh panel for mesh objects, the datapath will be resolvable on the data part. context.active_object.data (except for empties, whose data part is None)

added 78 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

MyOf the three choices my bet is that you're doing it wrong in that your o object is the lamp object, not the data part, or some other non LAMP data object.

import bpy
ocontext = bpy.context
#o = bpy.data.objects.get("Lamp") # assumes you have an ob named Lamp
o = context.active_object
if o:
    #o.energy 
    print("%s (%s)" % (o.name, o.type), getattr(o, "energy", "Has NO energy property"))
    o = o.data
    #o.data.energy
    if o:
        print("%s (%s)" % (o.name, o.type), getattr(o, "energy",  "Has NO energy property"))

If you grab a datapath from the DATA Properties panel, eg mesh panel for mesh objects, the datapath will be resolvable on the data part. context.active_object.data (except for empties, whose data part is None)

My bet is that your object is the lamp object, not the data part.

import bpy
o = bpy.data.objects.get("Lamp") # assumes you have an ob named Lamp
if o:
    #o.energy 
    print("%s (%s)" % (o.name, o.type), getattr(o, "energy", "Has NO energy property"))
    o = o.data
    #o.data.energy
    print("%s (%s)" % (o.name, o.type), getattr(o, "energy",  "Has NO energy property"))

If you grab a datapath from the DATA Properties panel, eg mesh panel for mesh objects, the datapath will be resolvable on the data part. context.active_object.data (except for empties, whose data part is None)

Of the three choices my bet is that you're doing it wrong in that your o object is the lamp object, not the data part, or some other non LAMP data object.

import bpy
context = bpy.context
#o = bpy.data.objects.get("Lamp") # assumes you have an ob named Lamp
o = context.active_object
if o:
    #o.energy 
    print("%s (%s)" % (o.name, o.type), getattr(o, "energy", "Has NO energy property"))
    o = o.data
    #o.data.energy
    if o:
        print("%s (%s)" % (o.name, o.type), getattr(o, "energy",  "Has NO energy property"))

If you grab a datapath from the DATA Properties panel, eg mesh panel for mesh objects, the datapath will be resolvable on the data part. context.active_object.data (except for empties, whose data part is None)

Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

My bet is that your object is the lamp object, not the data part.

import bpy
o = bpy.data.objects.get("Lamp") # assumes you have an ob named Lamp
if o:
    #o.energy 
    print("%s (%s)" % (o.name, o.type), getattr(o, "energy", "Has NO energy property"))
    o = o.data
    #o.data.energy
    print("%s (%s)" % (o.name, o.type), getattr(o, "energy",  "Has NO energy property"))

If you grab a datapath from the DATA Properties panel, eg mesh panel for mesh objects, the datapath will be resolvable on the data part. context.active_object.data (except for empties, whose data part is None)