Page MenuHome

Misleading code sample
Closed, ResolvedPublic


May not be a bug, but it is potentially misleading. In the document, there is this

Menu Item

.... The method used for adding a menu item is to append a draw function into an existing class:

def menu_func(self, context):

def register():

For docs on extending menus, see: bpy.types.Menu.

But using that register() function does not work, because it is not creating the ObjectCursorArray object first. This tutorial is for beginners, right? So, the reader would not have much knowledge about add-ons, and just follow the code. I have wasted a lot of time trying to add a menu with that code by installing a plugin (.py) file. After some time, that I figured out that it does not register the object, and sure enough, when I scrolled down furthur, there was "Bringing it all together" section which had

def register():

In my opinion, the code in the Menu Item section should have the line to register the class, too, in order the sample to work at that part of the document.