2

I would like to be able to control the power/energy of multiple lamps using a driver.

My idea is to have an empty that I would move on the Z axis between 0 and 1 to multiply the energy of each lamp.

On the lamp power attribute, I have Use Self enabled and this driver expression:

self.energy * var

enter image description here

Edit

It seems to provoke a kind of expression loop, and the value is increasing exponentially. So I guess my original "power" value should be defined elsewhere, maybe as a custom property of my lamp object ?

enter image description here

How could I link one to my driver expression?

Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187
gordie
  • 2,510
  • 3
  • 25
  • 47
  • 1
    IMO at issue here is self.energy is the power field you are driving. I don't get an error for this, but do get a constantly growing result.. which may lead to an error. See https://blender.stackexchange.com/questions/46903/how-to-view-python-error-messages re seeing the error message given, and post into question. – batFINGER Jan 11 '21 at 15:37
  • "This question already has an answer here" - nope, does not work with autorun python scripts. – gordie Jan 14 '21 at 10:46
  • Please post the error message printed into system console into question & will re-open. Please also take other note of my comment above in that you are driving the property with itself. – batFINGER Jan 14 '21 at 10:48
  • @batFINGER you were right. I edited the question. – gordie Jan 14 '21 at 11:07
  • whoops voted .. meant to give it a python tag first. Will need to wait on other re-open votes. Was an error message being printed to the system console. Don't get that ... end up with Inf or Nan (Infinity, or not a number as result) .. Re custom prop. Add one to lamp (data) called "prop" replace self.energy with self["prop"] in expression above. – batFINGER Jan 14 '21 at 11:19
  • it says "key 'power" not found. I do have a "power" custom property set. – gordie Jan 14 '21 at 11:34
  • Make sure it is a lamp custom property, not a lamp object custom property, or scene or viewlayer. Select the lamp object, in python console type in C.object.data["foogle"] = 1 There will now be a custom property on lamp named foogle. Your screen shot above suggests you are in object tab of properties, not in data tab. C.object["foogle"] instead of C.object.data["foogle"]. The self in driver for this case is C.object.data Or in UI terms First screen shot above (where driver is), is in data tab. Put the custom prop in the that ones "Custom Properties|". – batFINGER Jan 14 '21 at 11:40
  • this time I got it working ! thanks a LOT for your help here. – gordie Jan 14 '21 at 11:59
  • @Timaroberts please re-open, Have added an explanation via answer in linked dupe as to why. – batFINGER Jan 14 '21 at 12:44

0 Answers0