I am having issues creating a custom "Add Mesh" pie menu, Ive made a script, sampling from a number of different sources of code, that functions well enough from the text editor, However when i try to install it as an addon and enable it i get this error.

enter image description here

Which through reading a number of posts I believe I understand the "why" of why its happening, but my limited Python knowledge is hindering my ability to fix it. I believe the issue comes up at line 201 or so where i am trying to create a custom operator to assign different meshes with custom properties. At least thats what i understand it to be.

Ive tried altering the order of the class-list to change registration order, creating a class in itself for assigning the "type= bpy.props etc" attribute and registering that outside of the normal class list. Ive tried throwing an @classmethod or two in there (like i REALLY know what that's doing) but this is all mostly flailing in the dark and trying stuff i find in other stackexchange answers but nothing so far is helping.

I would greatly appreciate any help offered! Thank you in advance for your time.

My Script https://pastebin.com/t8DfUscG

Solutions I have tried, to the extent of my knowledge. This one being the main devlog post detailing the error, Which i cant figure how to use in my own script, but am sure would fix the issue.


As well as these other ones, as well as several other minor attempts.

Accessing bpy.context gives a '_RestrictContext' warning, how to fix this?

Application addon using bpy.data.scenes causes: AttributeError: '_RestrictData' object has no attribute 'scenes'

  • 1
    $\begingroup$ The issue is that you call the operator right away at the bottom of your script. Move that inside of the if __name__ == "__main__": and you won't get an error when installing. If you want to use it as an add-on you probably want to create a shortcut to the pie menu or add another operator which allows you to call the pie menu. $\endgroup$ – Robert Gützkow Nov 13 '19 at 18:42
  • $\begingroup$ Hi. Please include the code in the question body itself. If necessary, reduce the code to a smaller sample that still shows the issue. $\endgroup$ – Ray Mairlot Nov 13 '19 at 18:54
  • $\begingroup$ @RobertGützkow that did the trick! thank you I really appreciate it. $\endgroup$ – Jakemoyo Nov 14 '19 at 0:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.