Potential errors/final bl_idname requirements

The wiki (link) specifically states that

To prevent collisions 2.8x enforces naming conventions…This constraint applies to the bl_idname of each class (or the class name which uses it if no bl_idname is defined in the class)…

And specifically states that, for operators (which use the _OT_ naming scheme), this is a valid name:

OBJECT_OT_fancy_tool

Because the wiki states that “This constraint applies to the bl_idname of each class (or the class name which uses it if no bl_idname is defined in the class),” why does this bl_idname:

MAPLUS_OT_changetypebaseclass

Give an error:

RuntimeError: Error: Registering operator class: 'ChangeTypeBaseClass', invalid bl_idname 'MAPLUS_OT_changetypebaseclass', at position 0

I just want to FULLY understand the exact requirements for 2.80, because it seems that they are either unclear or incorrect as written (and this is blocking the release of my addon, I don’t want to release a version that does not work with an official 2.80 release or RC if the logic described on the wiki is in some way not finished, which seems to be the case).

Goal of this post is to fully settle these questions and arrive at a final answer.

Thanks :slight_smile: // 2.80 is fantastic, hoping to release a fully compliant, updated version of my addon for it.

@ideasman42 would probably know.

You should use bl_idname = "object.fancy_tool".

I’ve updated the wiki page to hopefully be more clear.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API/Addons#Naming

1 Like

Thanks for the help. I still have some questions…

The 2.8x and 2.7x rules conflict, as far as I can tell (I cannot find a good, exhaustive list of 2.7 rules, do we have one?). The only rules I have any knowledge of are that bl_idname must contain a dot and be lowercase. Problems/questions are listed inline:

ISSUE 1: (Conflicts/source link provided)

2.7 (?):

2.8:

^ The idname and class name can’t match if the prefix is required to be uppercase, but the bl_idname is supposed to be lowercase…which convention should we follow?

ISSUE 2: (Conflicts/source link provided)

It appears that operator classes are required to start with a specific word/category. Is this still true, or can all of my addon’s operators start with MYADDON_OT_DoSomething?

2.7 (?):

  • …The former must have valid Python syntax for a name, including a single dot; the part to the left of the dot must be the name of one of the valid categories of operators

https://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Advanced_Tutorials/Python_Scripting/Addon_Anatomy

ISSUE 3:

I have PropertyGroup (bpy) subclasses in my addon, but these seem to have no requirements in the wiki. I also have other non-bpy classes. It is confusing to see two different naming conventions, where some classes have a cryptic sequence of uppercase characters and others do not with no obvious reason why (in an addon especially). Is there any guidance for other bpy subclasses, to create coherent/consistent code?

MyProp_ZZ_DoSomething
MyBpySubclass_XY_DoSomething

  1. Operators have a different bl_idname convention than other types of classes like headers, menus and panels.

  2. There is no restriction on valid categories, that link is wrong. If the operator fits within an existing category it’s best to use that though.

  3. There is no guidance for other types of classes. The reason it is enforced for some classes is that they can conflict between addons.

If someone can glance at this diff and tell me these naming changes are correct (I believe they are, I get no errors on startup), I would super appreciate it…