# Why do scripts work when run from text editor but fail when run as an add-on

for example auto smooth set angle value fails when pie is run as an add-on but it works when run from the text editor

this makes no sense to me or I cannot figure out what is wrong. here is a link to the code of the complete pie script.

• Error message? AttributeError: '_RestrictContext' object has no attribute 'scene' ? If yes, see: wiki.blender.org/index.php/Extensions:2.6/Py/API_Changes Blender now restricts access to bpy.context and bpy.data while register() / unregister(). – p2or Jan 28 '16 at 8:14
• Sometimes when figuring ot what causes a bug you stumble into other potential bugs, you define UV_scale_X class multiple times - make each unique. – zeffii Jan 28 '16 at 9:12
• don't have a space in your python file name. name it something like some_pie_menu.py. it seems to work here, and does set the angle. In the event you get no warnings / errors you should start to look more carefully at other potential bugs and fixing those first. – zeffii Jan 28 '16 at 9:22