The Laplacian Lightning Generator addon broke with some recent API changes, as reported in this bug.

Attempting to enable it results in this:

Traceback (most recent call last):
  File "/usr/share/blender/2.68/scripts/modules/addon_utils.py", line 294, in enable
    mod = __import__(module_name)
  File "/usr/share/blender/2.68/scripts/addons_contrib/object_laplace_lightning.py", line 117, in <module>
    scn = bpy.context.scene
AttributeError: '_RestrictContext' object has no attribute 'scene'

As it was only some API changes that broke this, I assume (also from looking at the error) that this might be a fairly trivial problem (I'm inexperienced with python, so that might be a false assumption)

Are there a few simple changes I can make to get this addon working?

I know it works to run it in the text editor, however I would like to be able to use it as an addon without having to re run it every time I start blender.

  • $\begingroup$ Did you tried to run the script from text-editor, as specified on the website of the link you posted ? --> "UPDATE – 02.14.13 (...) An API change has made the addon not load. It has something to do bpy.scene.context. I’ll look into it when I have a chance. Fortunately the script will still run as a regular script. If you want to use it, just use the .blend file below or just load it in the text editor and hit run" $\endgroup$
    – Polosson
    Oct 11, 2013 at 21:14
  • $\begingroup$ @Polosson I did try that, and it works :). However I would like to be able to enable it once without having to restart it each time I restart blender. (I forgot to add this to the question originally..) $\endgroup$
    – gandalf3
    Oct 12, 2013 at 0:34

1 Answer 1


Read about the API change:

And here I posted an example script to show a possible solution:

There's also a hack to circumvent the context restriction: Add an app handler for the scene_update_post event, let it remove itself and run the initialization code in the body.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .